diff --git a/CHANGELOG.md b/CHANGELOG.md index ec23e82..bfa4691 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Change Log +## 22.0.0 + +* [BREAKING] Changed `$sequence` type from `int` to `string` for rows and documents +* [BREAKING] Renamed `IndexType` enum: split into `DatabasesIndexType` (for Databases) and `TablesDBIndexType` (for TablesDB) +* [BREAKING] Replaced `specification` parameter with `build_specification` and `runtime_specification` in `Functions#create`, `Functions#update`, `Sites#create`, `Sites#update` +* Added new `Project` service with full CRUD for project-level environment variables +* Added new `Webhooks` service with full CRUD for project webhooks (including `update_signature`) +* Added `Webhook` and `WebhookList` models +* Added `Users#update_impersonator` method for enabling/disabling user impersonation +* Added impersonation support: `set_impersonate_user_id`, `set_impersonate_user_email`, `set_impersonate_user_phone` on `Client` +* Added `impersonator` and `impersonator_user_id` fields to `User` model +* Added `deployment_retention` parameter to Functions and Sites create/update +* Added `start_command` parameter to Sites create/update +* Added `Documentsdb`, `Vectorsdb` values to `BackupServices` and `DatabaseType` enums +* Added `WebhooksRead`, `WebhooksWrite`, `ProjectRead`, `ProjectWrite` scopes +* Removed `get_queue_billing_project_aggregation`, `get_queue_billing_team_aggregation`, `get_queue_priority_builds`, `get_queue_region_manager`, `get_queue_threats` from `Health` service +* Updated `Log` model field descriptions to clarify impersonation behavior +* Updated `X-Appwrite-Response-Format` header to `1.9.0` +* Updated README badge to API version `1.9.0` and compatibility to server version `1.9.x` + ## 21.1.0 * Added get_console_pausing health endpoint to monitor console pausing. diff --git a/README.md b/README.md index dcf2d09..309889a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Ruby SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.8.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.9.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-ruby/releases).** +**This SDK is compatible with Appwrite server version 1.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-ruby/releases).** Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Ruby SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/appwrite.gemspec b/appwrite.gemspec index d4f2c87..7550e35 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '21.1.0' + spec.version = '22.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-index.md b/docs/examples/databases/create-index.md index 689855f..454ba82 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -15,7 +15,7 @@ result = databases.create_index( database_id: '', collection_id: '', key: '', - type: IndexType::KEY, + type: DatabasesIndexType::KEY, attributes: [], orders: [OrderBy::ASC], # optional lengths: [] # optional diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index c9358a7..ee2b479 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -29,6 +29,8 @@ result = functions.create( provider_branch: '', # optional provider_silent_mode: false, # optional provider_root_directory: '', # optional - specification: '' # optional + build_specification: '', # optional + runtime_specification: '', # optional + deployment_retention: 0 # optional ) ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index e06c276..8e883a5 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -29,6 +29,8 @@ result = functions.update( provider_branch: '', # optional provider_silent_mode: false, # optional provider_root_directory: '', # optional - specification: '' # optional + build_specification: '', # optional + runtime_specification: '', # optional + deployment_retention: 0 # optional ) ``` diff --git a/docs/examples/project/create-variable.md b/docs/examples/project/create-variable.md new file mode 100644 index 0000000..782cb51 --- /dev/null +++ b/docs/examples/project/create-variable.md @@ -0,0 +1,19 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.create_variable( + variable_id: '', + key: '', + value: '', + secret: false # optional +) +``` diff --git a/docs/examples/project/delete-variable.md b/docs/examples/project/delete-variable.md new file mode 100644 index 0000000..71c5bd8 --- /dev/null +++ b/docs/examples/project/delete-variable.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_variable( + variable_id: '' +) +``` diff --git a/docs/examples/project/get-variable.md b/docs/examples/project/get-variable.md new file mode 100644 index 0000000..7bea5e9 --- /dev/null +++ b/docs/examples/project/get-variable.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_variable( + variable_id: '' +) +``` diff --git a/docs/examples/project/list-variables.md b/docs/examples/project/list-variables.md new file mode 100644 index 0000000..a6af082 --- /dev/null +++ b/docs/examples/project/list-variables.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_variables( + queries: [], # optional + total: false # optional +) +``` diff --git a/docs/examples/project/update-variable.md b/docs/examples/project/update-variable.md new file mode 100644 index 0000000..fcfcac6 --- /dev/null +++ b/docs/examples/project/update-variable.md @@ -0,0 +1,19 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.update_variable( + variable_id: '', + key: '', # optional + value: '', # optional + secret: false # optional +) +``` diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md index 8177d7d..eb28cbf 100644 --- a/docs/examples/sites/create.md +++ b/docs/examples/sites/create.md @@ -21,6 +21,7 @@ result = sites.create( timeout: 1, # optional install_command: '', # optional build_command: '', # optional + start_command: '', # optional output_directory: '', # optional adapter: Adapter::STATIC, # optional installation_id: '', # optional @@ -29,6 +30,8 @@ result = sites.create( provider_branch: '', # optional provider_silent_mode: false, # optional provider_root_directory: '', # optional - specification: '' # optional + build_specification: '', # optional + runtime_specification: '', # optional + deployment_retention: 0 # optional ) ``` diff --git a/docs/examples/sites/update.md b/docs/examples/sites/update.md index de544d4..2476c3c 100644 --- a/docs/examples/sites/update.md +++ b/docs/examples/sites/update.md @@ -20,6 +20,7 @@ result = sites.update( timeout: 1, # optional install_command: '', # optional build_command: '', # optional + start_command: '', # optional output_directory: '', # optional build_runtime: BuildRuntime::NODE_14_5, # optional adapter: Adapter::STATIC, # optional @@ -29,6 +30,8 @@ result = sites.update( provider_branch: '', # optional provider_silent_mode: false, # optional provider_root_directory: '', # optional - specification: '' # optional + build_specification: '', # optional + runtime_specification: '', # optional + deployment_retention: 0 # optional ) ``` diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index d453b2a..7756a16 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -15,7 +15,7 @@ result = tables_db.create_index( database_id: '', table_id: '', key: '', - type: IndexType::KEY, + type: TablesDBIndexType::KEY, columns: [], orders: [OrderBy::ASC], # optional lengths: [] # optional diff --git a/docs/examples/users/update-impersonator.md b/docs/examples/users/update-impersonator.md new file mode 100644 index 0000000..b11d61f --- /dev/null +++ b/docs/examples/users/update-impersonator.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +users = Users.new(client) + +result = users.update_impersonator( + user_id: '', + impersonator: false +) +``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md new file mode 100644 index 0000000..7989c8b --- /dev/null +++ b/docs/examples/webhooks/create.md @@ -0,0 +1,23 @@ +```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 + +webhooks = Webhooks.new(client) + +result = webhooks.create( + webhook_id: '', + url: '', + name: '', + events: [], + enabled: false, # optional + security: false, # optional + http_user: '', # optional + http_pass: '' # optional +) +``` diff --git a/docs/examples/webhooks/delete.md b/docs/examples/webhooks/delete.md new file mode 100644 index 0000000..5951b7c --- /dev/null +++ b/docs/examples/webhooks/delete.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 + +webhooks = Webhooks.new(client) + +result = webhooks.delete( + webhook_id: '' +) +``` diff --git a/docs/examples/webhooks/get.md b/docs/examples/webhooks/get.md new file mode 100644 index 0000000..d81c129 --- /dev/null +++ b/docs/examples/webhooks/get.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 + +webhooks = Webhooks.new(client) + +result = webhooks.get( + webhook_id: '' +) +``` diff --git a/docs/examples/webhooks/list.md b/docs/examples/webhooks/list.md new file mode 100644 index 0000000..5416040 --- /dev/null +++ b/docs/examples/webhooks/list.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 + +webhooks = Webhooks.new(client) + +result = webhooks.list( + queries: [], # optional + total: false # optional +) +``` diff --git a/docs/examples/webhooks/update-signature.md b/docs/examples/webhooks/update-signature.md new file mode 100644 index 0000000..11acf67 --- /dev/null +++ b/docs/examples/webhooks/update-signature.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 + +webhooks = Webhooks.new(client) + +result = webhooks.update_signature( + webhook_id: '' +) +``` diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md new file mode 100644 index 0000000..51567d5 --- /dev/null +++ b/docs/examples/webhooks/update.md @@ -0,0 +1,23 @@ +```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 + +webhooks = Webhooks.new(client) + +result = webhooks.update( + webhook_id: '', + name: '', + url: '', + events: [], + enabled: false, # optional + security: false, # optional + http_user: '', # optional + http_pass: '' # optional +) +``` diff --git a/lib/appwrite.rb b/lib/appwrite.rb index 8bc6cfd..1b7eb9c 100644 --- a/lib/appwrite.rb +++ b/lib/appwrite.rb @@ -35,6 +35,7 @@ require_relative 'appwrite/models/runtime_list' require_relative 'appwrite/models/deployment_list' require_relative 'appwrite/models/execution_list' +require_relative 'appwrite/models/webhook_list' require_relative 'appwrite/models/country_list' require_relative 'appwrite/models/continent_list' require_relative 'appwrite/models/language_list' @@ -121,6 +122,7 @@ require_relative 'appwrite/models/framework_adapter' require_relative 'appwrite/models/deployment' require_relative 'appwrite/models/execution' +require_relative 'appwrite/models/webhook' require_relative 'appwrite/models/variable' require_relative 'appwrite/models/country' require_relative 'appwrite/models/continent' @@ -166,7 +168,7 @@ require_relative 'appwrite/enums/backup_services' require_relative 'appwrite/enums/relationship_type' require_relative 'appwrite/enums/relation_mutate' -require_relative 'appwrite/enums/index_type' +require_relative 'appwrite/enums/databases_index_type' require_relative 'appwrite/enums/order_by' require_relative 'appwrite/enums/runtime' require_relative 'appwrite/enums/scopes' @@ -182,6 +184,7 @@ require_relative 'appwrite/enums/adapter' require_relative 'appwrite/enums/compression' require_relative 'appwrite/enums/image_gravity' +require_relative 'appwrite/enums/tables_db_index_type' require_relative 'appwrite/enums/password_hash' require_relative 'appwrite/enums/messaging_provider_type' require_relative 'appwrite/enums/database_type' @@ -205,9 +208,11 @@ require_relative 'appwrite/services/health' require_relative 'appwrite/services/locale' require_relative 'appwrite/services/messaging' +require_relative 'appwrite/services/project' require_relative 'appwrite/services/sites' require_relative 'appwrite/services/storage' require_relative 'appwrite/services/tables_db' require_relative 'appwrite/services/teams' require_relative 'appwrite/services/tokens' require_relative 'appwrite/services/users' +require_relative 'appwrite/services/webhooks' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index 0cd7d62..a10c7a7 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'=> '21.1.0', - 'X-Appwrite-Response-Format' => '1.8.0' + 'x-sdk-version'=> '22.0.0', + 'X-Appwrite-Response-Format' => '1.9.0' } @endpoint = 'https://cloud.appwrite.io/v1' end @@ -97,6 +97,45 @@ def set_forwarded_user_agent(value) self end + # Set ImpersonateUserId + # + # Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + # + # @param [String] value The value to set for the ImpersonateUserId header + # + # @return [self] + def set_impersonate_user_id(value) + add_header('x-appwrite-impersonate-user-id', value) + + self + end + + # Set ImpersonateUserEmail + # + # Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + # + # @param [String] value The value to set for the ImpersonateUserEmail header + # + # @return [self] + def set_impersonate_user_email(value) + add_header('x-appwrite-impersonate-user-email', value) + + self + end + + # Set ImpersonateUserPhone + # + # Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + # + # @param [String] value The value to set for the ImpersonateUserPhone header + # + # @return [self] + def set_impersonate_user_phone(value) + add_header('x-appwrite-impersonate-user-phone', value) + + self + end + # Set endpoint. # # @param [String] endpoint The endpoint to set diff --git a/lib/appwrite/enums/backup_services.rb b/lib/appwrite/enums/backup_services.rb index ce763f7..79bd6d4 100644 --- a/lib/appwrite/enums/backup_services.rb +++ b/lib/appwrite/enums/backup_services.rb @@ -2,6 +2,9 @@ module Appwrite module Enums module BackupServices DATABASES = 'databases' + TABLESDB = 'tablesdb' + DOCUMENTSDB = 'documentsdb' + VECTORSDB = 'vectorsdb' FUNCTIONS = 'functions' STORAGE = 'storage' end diff --git a/lib/appwrite/enums/database_type.rb b/lib/appwrite/enums/database_type.rb index 2b65d44..1fd3996 100644 --- a/lib/appwrite/enums/database_type.rb +++ b/lib/appwrite/enums/database_type.rb @@ -3,6 +3,8 @@ module Enums module DatabaseType LEGACY = 'legacy' TABLESDB = 'tablesdb' + DOCUMENTSDB = 'documentsdb' + VECTORSDB = 'vectorsdb' end end end \ No newline at end of file diff --git a/lib/appwrite/enums/databases_index_type.rb b/lib/appwrite/enums/databases_index_type.rb new file mode 100644 index 0000000..ff4b7ff --- /dev/null +++ b/lib/appwrite/enums/databases_index_type.rb @@ -0,0 +1,10 @@ +module Appwrite + module Enums + module DatabasesIndexType + KEY = 'key' + FULLTEXT = 'fulltext' + UNIQUE = 'unique' + SPATIAL = 'spatial' + end + end +end \ No newline at end of file diff --git a/lib/appwrite/enums/scopes.rb b/lib/appwrite/enums/scopes.rb index 616a7f6..585722f 100644 --- a/lib/appwrite/enums/scopes.rb +++ b/lib/appwrite/enums/scopes.rb @@ -58,6 +58,10 @@ module Scopes ASSISTANT_READ = 'assistant.read' TOKENS_READ = 'tokens.read' TOKENS_WRITE = 'tokens.write' + WEBHOOKS_READ = 'webhooks.read' + WEBHOOKS_WRITE = 'webhooks.write' + PROJECT_READ = 'project.read' + PROJECT_WRITE = 'project.write' POLICIES_WRITE = 'policies.write' POLICIES_READ = 'policies.read' ARCHIVES_READ = 'archives.read' diff --git a/lib/appwrite/enums/index_type.rb b/lib/appwrite/enums/tables_db_index_type.rb similarity index 84% rename from lib/appwrite/enums/index_type.rb rename to lib/appwrite/enums/tables_db_index_type.rb index 4b95167..b8ccea6 100644 --- a/lib/appwrite/enums/index_type.rb +++ b/lib/appwrite/enums/tables_db_index_type.rb @@ -1,6 +1,6 @@ module Appwrite module Enums - module IndexType + module TablesDBIndexType KEY = 'key' FULLTEXT = 'fulltext' UNIQUE = 'unique' diff --git a/lib/appwrite/enums/template_reference_type.rb b/lib/appwrite/enums/template_reference_type.rb index fc75cc7..4fe8a4c 100644 --- a/lib/appwrite/enums/template_reference_type.rb +++ b/lib/appwrite/enums/template_reference_type.rb @@ -1,8 +1,8 @@ module Appwrite module Enums module TemplateReferenceType - BRANCH = 'branch' COMMIT = 'commit' + BRANCH = 'branch' TAG = 'tag' end end diff --git a/lib/appwrite/models/database.rb b/lib/appwrite/models/database.rb index 6ee3169..8f1d295 100644 --- a/lib/appwrite/models/database.rb +++ b/lib/appwrite/models/database.rb @@ -64,6 +64,8 @@ def validate_type(type) valid_type = [ Appwrite::Enums::DatabaseType::LEGACY, Appwrite::Enums::DatabaseType::TABLESDB, + Appwrite::Enums::DatabaseType::DOCUMENTSDB, + Appwrite::Enums::DatabaseType::VECTORSDB, ] unless valid_type.include?(type) diff --git a/lib/appwrite/models/function.rb b/lib/appwrite/models/function.rb index ae155e8..7dcb520 100644 --- a/lib/appwrite/models/function.rb +++ b/lib/appwrite/models/function.rb @@ -12,6 +12,7 @@ class Function attr_reader :live attr_reader :logging attr_reader :runtime + attr_reader :deployment_retention attr_reader :deployment_id attr_reader :deployment_created_at attr_reader :latest_deployment_id @@ -30,7 +31,8 @@ class Function attr_reader :provider_branch attr_reader :provider_root_directory attr_reader :provider_silent_mode - attr_reader :specification + attr_reader :build_specification + attr_reader :runtime_specification def initialize( id:, @@ -42,6 +44,7 @@ def initialize( live:, logging:, runtime:, + deployment_retention:, deployment_id:, deployment_created_at:, latest_deployment_id:, @@ -60,7 +63,8 @@ def initialize( provider_branch:, provider_root_directory:, provider_silent_mode:, - specification: + build_specification:, + runtime_specification: ) @id = id @created_at = created_at @@ -71,6 +75,7 @@ def initialize( @live = live @logging = logging @runtime = runtime + @deployment_retention = deployment_retention @deployment_id = deployment_id @deployment_created_at = deployment_created_at @latest_deployment_id = latest_deployment_id @@ -89,7 +94,8 @@ def initialize( @provider_branch = provider_branch @provider_root_directory = provider_root_directory @provider_silent_mode = provider_silent_mode - @specification = specification + @build_specification = build_specification + @runtime_specification = runtime_specification end def self.from(map:) @@ -103,6 +109,7 @@ def self.from(map:) live: map["live"], logging: map["logging"], runtime: map["runtime"], + deployment_retention: map["deploymentRetention"], deployment_id: map["deploymentId"], deployment_created_at: map["deploymentCreatedAt"], latest_deployment_id: map["latestDeploymentId"], @@ -121,7 +128,8 @@ def self.from(map:) provider_branch: map["providerBranch"], provider_root_directory: map["providerRootDirectory"], provider_silent_mode: map["providerSilentMode"], - specification: map["specification"] + build_specification: map["buildSpecification"], + runtime_specification: map["runtimeSpecification"] ) end @@ -136,6 +144,7 @@ def to_map "live": @live, "logging": @logging, "runtime": @runtime, + "deploymentRetention": @deployment_retention, "deploymentId": @deployment_id, "deploymentCreatedAt": @deployment_created_at, "latestDeploymentId": @latest_deployment_id, @@ -154,7 +163,8 @@ def to_map "providerBranch": @provider_branch, "providerRootDirectory": @provider_root_directory, "providerSilentMode": @provider_silent_mode, - "specification": @specification + "buildSpecification": @build_specification, + "runtimeSpecification": @runtime_specification } end end diff --git a/lib/appwrite/models/site.rb b/lib/appwrite/models/site.rb index 466fcbf..4223aa7 100644 --- a/lib/appwrite/models/site.rb +++ b/lib/appwrite/models/site.rb @@ -11,6 +11,7 @@ class Site attr_reader :live attr_reader :logging attr_reader :framework + attr_reader :deployment_retention attr_reader :deployment_id attr_reader :deployment_created_at attr_reader :deployment_screenshot_light @@ -22,13 +23,15 @@ class Site attr_reader :timeout attr_reader :install_command attr_reader :build_command + attr_reader :start_command attr_reader :output_directory attr_reader :installation_id attr_reader :provider_repository_id attr_reader :provider_branch attr_reader :provider_root_directory attr_reader :provider_silent_mode - attr_reader :specification + attr_reader :build_specification + attr_reader :runtime_specification attr_reader :build_runtime attr_reader :adapter attr_reader :fallback_file @@ -42,6 +45,7 @@ def initialize( live:, logging:, framework:, + deployment_retention:, deployment_id:, deployment_created_at:, deployment_screenshot_light:, @@ -53,13 +57,15 @@ def initialize( timeout:, install_command:, build_command:, + start_command:, output_directory:, installation_id:, provider_repository_id:, provider_branch:, provider_root_directory:, provider_silent_mode:, - specification:, + build_specification:, + runtime_specification:, build_runtime:, adapter:, fallback_file: @@ -72,6 +78,7 @@ def initialize( @live = live @logging = logging @framework = framework + @deployment_retention = deployment_retention @deployment_id = deployment_id @deployment_created_at = deployment_created_at @deployment_screenshot_light = deployment_screenshot_light @@ -83,13 +90,15 @@ def initialize( @timeout = timeout @install_command = install_command @build_command = build_command + @start_command = start_command @output_directory = output_directory @installation_id = installation_id @provider_repository_id = provider_repository_id @provider_branch = provider_branch @provider_root_directory = provider_root_directory @provider_silent_mode = provider_silent_mode - @specification = specification + @build_specification = build_specification + @runtime_specification = runtime_specification @build_runtime = build_runtime @adapter = adapter @fallback_file = fallback_file @@ -105,6 +114,7 @@ def self.from(map:) live: map["live"], logging: map["logging"], framework: map["framework"], + deployment_retention: map["deploymentRetention"], deployment_id: map["deploymentId"], deployment_created_at: map["deploymentCreatedAt"], deployment_screenshot_light: map["deploymentScreenshotLight"], @@ -116,13 +126,15 @@ def self.from(map:) timeout: map["timeout"], install_command: map["installCommand"], build_command: map["buildCommand"], + start_command: map["startCommand"], output_directory: map["outputDirectory"], installation_id: map["installationId"], provider_repository_id: map["providerRepositoryId"], provider_branch: map["providerBranch"], provider_root_directory: map["providerRootDirectory"], provider_silent_mode: map["providerSilentMode"], - specification: map["specification"], + build_specification: map["buildSpecification"], + runtime_specification: map["runtimeSpecification"], build_runtime: map["buildRuntime"], adapter: map["adapter"], fallback_file: map["fallbackFile"] @@ -139,6 +151,7 @@ def to_map "live": @live, "logging": @logging, "framework": @framework, + "deploymentRetention": @deployment_retention, "deploymentId": @deployment_id, "deploymentCreatedAt": @deployment_created_at, "deploymentScreenshotLight": @deployment_screenshot_light, @@ -150,13 +163,15 @@ def to_map "timeout": @timeout, "installCommand": @install_command, "buildCommand": @build_command, + "startCommand": @start_command, "outputDirectory": @output_directory, "installationId": @installation_id, "providerRepositoryId": @provider_repository_id, "providerBranch": @provider_branch, "providerRootDirectory": @provider_root_directory, "providerSilentMode": @provider_silent_mode, - "specification": @specification, + "buildSpecification": @build_specification, + "runtimeSpecification": @runtime_specification, "buildRuntime": @build_runtime, "adapter": @adapter, "fallbackFile": @fallback_file diff --git a/lib/appwrite/models/user.rb b/lib/appwrite/models/user.rb index 6e47d77..ec03e29 100644 --- a/lib/appwrite/models/user.rb +++ b/lib/appwrite/models/user.rb @@ -22,6 +22,8 @@ class User attr_reader :prefs attr_reader :targets attr_reader :accessed_at + attr_reader :impersonator + attr_reader :impersonator_user_id def initialize( id:, @@ -42,7 +44,9 @@ def initialize( mfa:, prefs:, targets:, - accessed_at: + accessed_at:, + impersonator: , + impersonator_user_id: ) @id = id @created_at = created_at @@ -63,6 +67,8 @@ def initialize( @prefs = prefs @targets = targets @accessed_at = accessed_at + @impersonator = impersonator + @impersonator_user_id = impersonator_user_id end def self.from(map:) @@ -85,7 +91,9 @@ def self.from(map:) mfa: map["mfa"], prefs: Preferences.from(map: map["prefs"]), targets: map["targets"].map { |it| Target.from(map: it) }, - accessed_at: map["accessedAt"] + accessed_at: map["accessedAt"], + impersonator: map["impersonator"], + impersonator_user_id: map["impersonatorUserId"] ) end @@ -109,7 +117,9 @@ def to_map "mfa": @mfa, "prefs": @prefs.to_map, "targets": @targets.map { |it| it.to_map }, - "accessedAt": @accessed_at + "accessedAt": @accessed_at, + "impersonator": @impersonator, + "impersonatorUserId": @impersonator_user_id } end end diff --git a/lib/appwrite/models/webhook.rb b/lib/appwrite/models/webhook.rb new file mode 100644 index 0000000..6229a2b --- /dev/null +++ b/lib/appwrite/models/webhook.rb @@ -0,0 +1,87 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Webhook + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + 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 :enabled + attr_reader :logs + attr_reader :attempts + + def initialize( + id:, + created_at:, + updated_at:, + name:, + url:, + events:, + security:, + http_user:, + http_pass:, + signature_key:, + enabled:, + logs:, + attempts: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @url = url + @events = events + @security = security + @http_user = http_user + @http_pass = http_pass + @signature_key = signature_key + @enabled = enabled + @logs = logs + @attempts = attempts + end + + def self.from(map:) + Webhook.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + url: map["url"], + events: map["events"], + security: map["security"], + http_user: map["httpUser"], + http_pass: map["httpPass"], + signature_key: map["signatureKey"], + enabled: map["enabled"], + logs: map["logs"], + attempts: map["attempts"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "url": @url, + "events": @events, + "security": @security, + "httpUser": @http_user, + "httpPass": @http_pass, + "signatureKey": @signature_key, + "enabled": @enabled, + "logs": @logs, + "attempts": @attempts + } + end + end + end +end diff --git a/lib/appwrite/models/webhook_list.rb b/lib/appwrite/models/webhook_list.rb new file mode 100644 index 0000000..0225609 --- /dev/null +++ b/lib/appwrite/models/webhook_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class WebhookList + attr_reader :total + attr_reader :webhooks + + def initialize( + total:, + webhooks: + ) + @total = total + @webhooks = webhooks + end + + def self.from(map:) + WebhookList.new( + total: map["total"], + webhooks: map["webhooks"].map { |it| Webhook.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "webhooks": @webhooks.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/services/databases.rb b/lib/appwrite/services/databases.rb index eda6f18..dabe67c 100644 --- a/lib/appwrite/services/databases.rb +++ b/lib/appwrite/services/databases.rb @@ -3300,7 +3300,7 @@ def list_indexes(database_id:, collection_id:, queries: nil, total: nil) # @param [String] database_id Database ID. # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). # @param [String] key Index Key. - # @param [IndexType] type Index type. + # @param [DatabasesIndexType] type Index type. # @param [Array] attributes Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. # @param [Array] orders Array of index orders. Maximum of 100 orders are allowed. # @param [Array] lengths Length of index. Maximum of 100 diff --git a/lib/appwrite/services/functions.rb b/lib/appwrite/services/functions.rb index 3104636..f10a6f6 100644 --- a/lib/appwrite/services/functions.rb +++ b/lib/appwrite/services/functions.rb @@ -58,10 +58,12 @@ def list(queries: nil, search: nil, total: nil) # @param [String] provider_branch Production branch for the repo linked to the function. # @param [] provider_silent_mode Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. # @param [String] provider_root_directory Path to function code in the linked repo. - # @param [String] specification Runtime specification for the function and builds. + # @param [String] build_specification Build specification for the function deployments. + # @param [String] runtime_specification Runtime specification for the function executions. + # @param [Integer] deployment_retention Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. # # @return [Function] - def create(function_id:, name:, runtime:, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, scopes: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, specification: nil) + def create(function_id:, name:, runtime:, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, scopes: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, build_specification: nil, runtime_specification: nil, deployment_retention: nil) api_path = '/functions' if function_id.nil? @@ -94,7 +96,9 @@ def create(function_id:, name:, runtime:, execute: nil, events: nil, schedule: n providerBranch: provider_branch, providerSilentMode: provider_silent_mode, providerRootDirectory: provider_root_directory, - specification: specification, + buildSpecification: build_specification, + runtimeSpecification: runtime_specification, + deploymentRetention: deployment_retention, } api_headers = { @@ -201,10 +205,12 @@ def get(function_id:) # @param [String] provider_branch Production branch for the repo linked to the function # @param [] provider_silent_mode Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. # @param [String] provider_root_directory Path to function code in the linked repo. - # @param [String] specification Runtime specification for the function and builds. + # @param [String] build_specification Build specification for the function deployments. + # @param [String] runtime_specification Runtime specification for the function executions. + # @param [Integer] deployment_retention Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. # # @return [Function] - def update(function_id:, name:, runtime: nil, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, scopes: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, specification: nil) + def update(function_id:, name:, runtime: nil, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, scopes: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, build_specification: nil, runtime_specification: nil, deployment_retention: nil) api_path = '/functions/{functionId}' .gsub('{functionId}', function_id) @@ -233,7 +239,9 @@ def update(function_id:, name:, runtime: nil, execute: nil, events: nil, schedul providerBranch: provider_branch, providerSilentMode: provider_silent_mode, providerRootDirectory: provider_root_directory, - specification: specification, + buildSpecification: build_specification, + runtimeSpecification: runtime_specification, + deploymentRetention: deployment_retention, } api_headers = { diff --git a/lib/appwrite/services/health.rb b/lib/appwrite/services/health.rb index 9d30ea4..ae8d0b3 100644 --- a/lib/appwrite/services/health.rb +++ b/lib/appwrite/services/health.rb @@ -195,54 +195,6 @@ def get_queue_audits(threshold: nil) ) end - # Get billing project aggregation queue. - # - # @param [Integer] threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. - # - # @return [HealthQueue] - def get_queue_billing_project_aggregation(threshold: nil) - api_path = '/health/queue/billing-project-aggregation' - - api_params = { - threshold: threshold, - } - - api_headers = { - } - - @client.call( - method: 'GET', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::HealthQueue - ) - end - - # Get billing team aggregation queue. - # - # @param [Integer] threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. - # - # @return [HealthQueue] - def get_queue_billing_team_aggregation(threshold: nil) - api_path = '/health/queue/billing-team-aggregation' - - api_params = { - threshold: threshold, - } - - api_headers = { - } - - @client.call( - method: 'GET', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::HealthQueue - ) - end - # Get the number of builds that are waiting to be processed in the Appwrite # internal queue server. # @@ -268,30 +220,6 @@ def get_queue_builds(threshold: nil) ) end - # Get the priority builds queue size. - # - # @param [Integer] threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 500. - # - # @return [HealthQueue] - def get_queue_priority_builds(threshold: nil) - api_path = '/health/queue/builds-priority' - - api_params = { - threshold: threshold, - } - - api_headers = { - } - - @client.call( - method: 'GET', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::HealthQueue - ) - end - # Get the number of certificates that are waiting to be issued against # [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue # server. @@ -526,30 +454,6 @@ def get_queue_migrations(threshold: nil) ) end - # Get region manager queue. - # - # @param [Integer] threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100. - # - # @return [HealthQueue] - def get_queue_region_manager(threshold: nil) - api_path = '/health/queue/region-manager' - - api_params = { - threshold: threshold, - } - - api_headers = { - } - - @client.call( - method: 'GET', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::HealthQueue - ) - end - # Get the number of metrics that are waiting to be processed in the Appwrite # stats resources queue. # @@ -600,30 +504,6 @@ def get_queue_usage(threshold: nil) ) end - # Get threats queue. - # - # @param [Integer] threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100. - # - # @return [HealthQueue] - def get_queue_threats(threshold: nil) - api_path = '/health/queue/threats' - - api_params = { - threshold: threshold, - } - - api_headers = { - } - - @client.call( - method: 'GET', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::HealthQueue - ) - end - # Get the number of webhooks that are waiting to be processed in the Appwrite # internal queue server. # diff --git a/lib/appwrite/services/project.rb b/lib/appwrite/services/project.rb new file mode 100644 index 0000000..d9b8b14 --- /dev/null +++ b/lib/appwrite/services/project.rb @@ -0,0 +1,172 @@ +#frozen_string_literal: true + +module Appwrite + class Project < Service + + def initialize(client) + @client = client + 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 + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [VariableList] + def list_variables(queries: nil, total: nil) + api_path = '/project/variables' + + api_params = { + queries: queries, + total: total, + } + + api_headers = { + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::VariableList + ) + end + + # Create a new project environment variable. These variables can be accessed + # by all functions and sites in the project. + # + # @param [String] variable_id Variable ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # @param [String] key Variable key. Max length: 255 chars. + # @param [String] value Variable value. Max length: 8192 chars. + # @param [] secret Secret variables can be updated or deleted, but only projects can read them during build and runtime. + # + # @return [Variable] + def create_variable(variable_id:, key:, value:, secret: nil) + api_path = '/project/variables' + + if variable_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "variableId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + api_params = { + variableId: variable_id, + key: key, + value: value, + secret: secret, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Variable + ) + end + + # Get a variable by its unique ID. + # + # @param [String] variable_id Variable ID. + # + # @return [Variable] + def get_variable(variable_id:) + api_path = '/project/variables/{variableId}' + .gsub('{variableId}', variable_id) + + if variable_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "variableId"') + end + + api_params = { + } + + api_headers = { + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Variable + ) + end + + # Update variable by its unique ID. + # + # @param [String] variable_id Variable ID. + # @param [String] key Variable key. Max length: 255 chars. + # @param [String] value Variable value. Max length: 8192 chars. + # @param [] secret Secret variables can be updated or deleted, but only projects can read them during build and runtime. + # + # @return [Variable] + def update_variable(variable_id:, key: nil, value: nil, secret: nil) + api_path = '/project/variables/{variableId}' + .gsub('{variableId}', variable_id) + + if variable_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "variableId"') + end + + api_params = { + key: key, + value: value, + secret: secret, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Variable + ) + end + + # Delete a variable by its unique ID. + # + # @param [String] variable_id Variable ID. + # + # @return [] + def delete_variable(variable_id:) + api_path = '/project/variables/{variableId}' + .gsub('{variableId}', variable_id) + + if variable_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "variableId"') + end + + api_params = { + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + end + + end +end \ No newline at end of file diff --git a/lib/appwrite/services/sites.rb b/lib/appwrite/services/sites.rb index 511199f..37893e1 100644 --- a/lib/appwrite/services/sites.rb +++ b/lib/appwrite/services/sites.rb @@ -47,6 +47,7 @@ def list(queries: nil, search: nil, total: nil) # @param [Integer] timeout Maximum request time in seconds. # @param [String] install_command Install Command. # @param [String] build_command Build Command. + # @param [String] start_command Custom start command. Leave empty to use default. # @param [String] output_directory Output Directory for site. # @param [Adapter] adapter Framework adapter defining rendering strategy. Allowed values are: static, ssr # @param [String] installation_id Appwrite Installation ID for VCS (Version Control System) deployment. @@ -55,10 +56,12 @@ def list(queries: nil, search: nil, total: nil) # @param [String] provider_branch Production branch for the repo linked to the site. # @param [] provider_silent_mode Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. # @param [String] provider_root_directory Path to site code in the linked repo. - # @param [String] specification Framework specification for the site and builds. + # @param [String] build_specification Build specification for the site deployments. + # @param [String] runtime_specification Runtime specification for the SSR executions. + # @param [Integer] deployment_retention Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. # # @return [Site] - def create(site_id:, name:, framework:, build_runtime:, enabled: nil, logging: nil, timeout: nil, install_command: nil, build_command: nil, output_directory: nil, adapter: nil, installation_id: nil, fallback_file: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, specification: nil) + def create(site_id:, name:, framework:, build_runtime:, enabled: nil, logging: nil, timeout: nil, install_command: nil, build_command: nil, start_command: nil, output_directory: nil, adapter: nil, installation_id: nil, fallback_file: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, build_specification: nil, runtime_specification: nil, deployment_retention: nil) api_path = '/sites' if site_id.nil? @@ -86,6 +89,7 @@ def create(site_id:, name:, framework:, build_runtime:, enabled: nil, logging: n timeout: timeout, installCommand: install_command, buildCommand: build_command, + startCommand: start_command, outputDirectory: output_directory, buildRuntime: build_runtime, adapter: adapter, @@ -95,7 +99,9 @@ def create(site_id:, name:, framework:, build_runtime:, enabled: nil, logging: n providerBranch: provider_branch, providerSilentMode: provider_silent_mode, providerRootDirectory: provider_root_directory, - specification: specification, + buildSpecification: build_specification, + runtimeSpecification: runtime_specification, + deploymentRetention: deployment_retention, } api_headers = { @@ -194,6 +200,7 @@ def get(site_id:) # @param [Integer] timeout Maximum request time in seconds. # @param [String] install_command Install Command. # @param [String] build_command Build Command. + # @param [String] start_command Custom start command. Leave empty to use default. # @param [String] output_directory Output Directory for site. # @param [BuildRuntime] build_runtime Runtime to use during build step. # @param [Adapter] adapter Framework adapter defining rendering strategy. Allowed values are: static, ssr @@ -203,10 +210,12 @@ def get(site_id:) # @param [String] provider_branch Production branch for the repo linked to the site. # @param [] provider_silent_mode Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. # @param [String] provider_root_directory Path to site code in the linked repo. - # @param [String] specification Framework specification for the site and builds. + # @param [String] build_specification Build specification for the site deployments. + # @param [String] runtime_specification Runtime specification for the SSR executions. + # @param [Integer] deployment_retention Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. # # @return [Site] - def update(site_id:, name:, framework:, enabled: nil, logging: nil, timeout: nil, install_command: nil, build_command: nil, output_directory: nil, build_runtime: nil, adapter: nil, fallback_file: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, specification: nil) + def update(site_id:, name:, framework:, enabled: nil, logging: nil, timeout: nil, install_command: nil, build_command: nil, start_command: nil, output_directory: nil, build_runtime: nil, adapter: nil, fallback_file: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, build_specification: nil, runtime_specification: nil, deployment_retention: nil) api_path = '/sites/{siteId}' .gsub('{siteId}', site_id) @@ -230,6 +239,7 @@ def update(site_id:, name:, framework:, enabled: nil, logging: nil, timeout: nil timeout: timeout, installCommand: install_command, buildCommand: build_command, + startCommand: start_command, outputDirectory: output_directory, buildRuntime: build_runtime, adapter: adapter, @@ -239,7 +249,9 @@ def update(site_id:, name:, framework:, enabled: nil, logging: nil, timeout: nil providerBranch: provider_branch, providerSilentMode: provider_silent_mode, providerRootDirectory: provider_root_directory, - specification: specification, + buildSpecification: build_specification, + runtimeSpecification: runtime_specification, + deploymentRetention: deployment_retention, } api_headers = { diff --git a/lib/appwrite/services/tables_db.rb b/lib/appwrite/services/tables_db.rb index dbbcb08..67f3587 100644 --- a/lib/appwrite/services/tables_db.rb +++ b/lib/appwrite/services/tables_db.rb @@ -2582,7 +2582,7 @@ def list_indexes(database_id:, table_id:, queries: nil, total: nil) # @param [String] database_id Database ID. # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). # @param [String] key Index Key. - # @param [IndexType] type Index type. + # @param [TablesDBIndexType] type Index type. # @param [Array] columns Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. # @param [Array] orders Array of index orders. Maximum of 100 orders are allowed. # @param [Array] lengths Length of index. Maximum of 100 diff --git a/lib/appwrite/services/users.rb b/lib/appwrite/services/users.rb index f79f38f..cd37aa0 100644 --- a/lib/appwrite/services/users.rb +++ b/lib/appwrite/services/users.rb @@ -10,7 +10,7 @@ def initialize(client) # Get a list of all the project's users. 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, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels + # @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, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels, impersonator # @param [String] search Search term to filter your list results. Max length: 256 chars. # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # @@ -598,6 +598,46 @@ def update_email(user_id:, email:) ) end + # Enable or disable whether a user can impersonate other users. When + # impersonation headers are used, the request runs as the target user for API + # behavior, while internal audit logs still attribute the action to the + # original impersonator and store the impersonated target details only in + # internal audit payload data. + # + # + # @param [String] user_id User ID. + # @param [] impersonator Whether the user can impersonate other users. When true, the user can browse project users to choose a target and can pass impersonation headers to act as that user. Internal audit logs still attribute impersonated actions to the original impersonator and store the target user details only in internal audit payload data. + # + # @return [User] + def update_impersonator(user_id:, impersonator:) + api_path = '/users/{userId}/impersonator' + .gsub('{userId}', user_id) + + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if impersonator.nil? + raise Appwrite::Exception.new('Missing required parameter: "impersonator"') + end + + api_params = { + impersonator: impersonator, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::User + ) + end + # Use this endpoint to create a JSON Web Token for user by its unique ID. You # can use the resulting JWT to authenticate on behalf of the user. The JWT # secret will become invalid if the session it uses gets deleted. diff --git a/lib/appwrite/services/webhooks.rb b/lib/appwrite/services/webhooks.rb new file mode 100644 index 0000000..19102f5 --- /dev/null +++ b/lib/appwrite/services/webhooks.rb @@ -0,0 +1,239 @@ +#frozen_string_literal: true + +module Appwrite + class Webhooks < Service + + def initialize(client) + @client = client + end + + # 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 [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [WebhookList] + def list(queries: nil, total: nil) + api_path = '/webhooks' + + api_params = { + queries: queries, + total: total, + } + + api_headers = { + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WebhookList + ) + end + + # Create a new webhook. Use this endpoint to configure a URL that will + # receive events from Appwrite when specific events occur. + # + # @param [String] webhook_id Webhook 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] url Webhook URL. + # @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. + # + # @return [Webhook] + def create(webhook_id:, url:, name:, events:, enabled: nil, security: nil, http_user: nil, http_pass: nil) + api_path = '/webhooks' + + if webhook_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "webhookId"') + end + + if url.nil? + raise Appwrite::Exception.new('Missing required parameter: "url"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if events.nil? + raise Appwrite::Exception.new('Missing required parameter: "events"') + end + + api_params = { + webhookId: webhook_id, + url: url, + name: name, + events: events, + enabled: enabled, + security: security, + httpUser: http_user, + httpPass: http_pass, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Webhook + ) + end + + # Get a webhook by its unique ID. This endpoint returns details about a + # specific webhook configured for a project. + # + # @param [String] webhook_id Webhook ID. + # + # @return [Webhook] + def get(webhook_id:) + api_path = '/webhooks/{webhookId}' + .gsub('{webhookId}', webhook_id) + + if webhook_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "webhookId"') + end + + api_params = { + } + + api_headers = { + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Webhook + ) + end + + # Update a webhook by its unique ID. Use this endpoint to update the URL, + # events, or status of an existing webhook. + # + # @param [String] webhook_id Webhook ID. + # @param [String] name Webhook name. Max length: 128 chars. + # @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. + # + # @return [Webhook] + def update(webhook_id:, name:, url:, events:, enabled: nil, security: nil, http_user: nil, http_pass: nil) + api_path = '/webhooks/{webhookId}' + .gsub('{webhookId}', webhook_id) + + if webhook_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "webhookId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if url.nil? + raise Appwrite::Exception.new('Missing required parameter: "url"') + end + + if events.nil? + raise Appwrite::Exception.new('Missing required parameter: "events"') + end + + api_params = { + name: name, + url: url, + events: events, + enabled: enabled, + security: security, + httpUser: http_user, + httpPass: http_pass, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Webhook + ) + end + + # Delete a webhook by its unique ID. Once deleted, the webhook will no longer + # receive project events. + # + # @param [String] webhook_id Webhook ID. + # + # @return [] + def delete(webhook_id:) + api_path = '/webhooks/{webhookId}' + .gsub('{webhookId}', webhook_id) + + if webhook_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "webhookId"') + 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 webhook signature key. This endpoint can be used to regenerate + # the signature key used to sign and validate payload deliveries for a + # specific webhook. + # + # @param [String] webhook_id Webhook ID. + # + # @return [Webhook] + def update_signature(webhook_id:) + api_path = '/webhooks/{webhookId}/signature' + .gsub('{webhookId}', webhook_id) + + if webhook_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "webhookId"') + end + + api_params = { + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Webhook + ) + end + + end +end \ No newline at end of file