diff --git a/CHANGELOG.md b/CHANGELOG.md index 240e5b7c..cdc8ff1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Change Log +## 28.4.0 + +* Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones +* Added: `waf` service with bypass, challenge, deny, rate-limit and redirect rules +* Added: `account.createEmailVerificationOTP`, `updateEmailVerificationOTP`, `createRecoveryOTP` and `updateRecoveryOTP` +* Added: `account.createIdTokenSession` and `Identity.providerIdToken` +* Added: `oauth2.introspect` +* Added: project environments with `project.createEnvironment`, `getEnvironment`, `listEnvironments`, `updateEnvironment` and `deleteEnvironment` +* Added: `organization.createEphemeralProjectKey`, `listProjectKeys`, `getProjectKey`, `updateProjectKey` and `deleteProjectKey` +* Added: Kakao, TikTok and Webflow OAuth2 providers with `project.updateOAuth2Kakao`, `updateOAuth2TikTok` and `updateOAuth2Webflow` +* Added: optional `prompt` on the Auth0, Discord, GitHub, Microsoft, Okta, Salesforce and Zoho OAuth2 settings, and native client IDs on Apple and Google +* Added: `project.updatePasswordPwnedPolicy`, `project.updatePasswordRotationPolicy` and `User.passwordPwned` +* Added: `messaging.createAppwriteProvider` and `messaging.updateAppwriteProvider` +* Added: optional `replyToEmail` and `replyToName` on email messages, `channelId` on push messages, and `qos` and `expiry` on topics +* Added: `avatars.updatePhoto` and `avatars.deletePhoto` +* Added: optional `duration` on `account.createEmailPasswordSession`, `current` on `account.deleteSessions`, `membershipId` on `teams.createMembership` and `fingerprints` on Android platforms +* Added: optional `total` on the locale, transaction, runtime, specification and framework lists +* Added: `dart-3.13` and `flutter-3.47` runtimes, the `jaspr` framework, the `trigram` index type, `auto` image gravity, the `dedicatedDatabase` proxy rule resource type, OTP email templates and new key scopes +* Added: optional fields on `BillingPlan`, `DedicatedDatabase`, `DedicatedDatabaseSpecification`, `Project` and `Topic`, and `free` and `start` in `BillingPlanGroup` +* Fixed: OAuth2 provider models with an array `prompt` no longer raise `TypeError` + ## 28.3.2 * Fixed: `Project` responses no longer raise `ArgumentError` on the `oauth2` service diff --git a/appwrite.gemspec b/appwrite.gemspec index 61abd90f..7fe70b3b 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '28.3.2' + spec.version = '28.4.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/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md index 57ab742d..2db01b74 100644 --- a/docs/examples/account/create-email-password-session.md +++ b/docs/examples/account/create-email-password-session.md @@ -12,6 +12,7 @@ account = Account.new(client) result = account.create_email_password_session( email: 'email@example.com', - password: 'password' + password: 'password', + duration: 60 # optional ) ``` diff --git a/docs/examples/account/create-email-verification-otp.md b/docs/examples/account/create-email-verification-otp.md new file mode 100644 index 00000000..618575b3 --- /dev/null +++ b/docs/examples/account/create-email-verification-otp.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_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.create_email_verification_otp( + phrase: false # optional +) +``` diff --git a/docs/examples/account/create-id-token-session.md b/docs/examples/account/create-id-token-session.md new file mode 100644 index 00000000..3a244017 --- /dev/null +++ b/docs/examples/account/create-id-token-session.md @@ -0,0 +1,22 @@ +```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_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.create_id_token_session( + provider: IdTokenProvider::APPLE, + id_token: '', + nonce: '', # optional + access_token: '', # optional + access_token_expiry: 0, # optional + name: '' # optional +) +``` diff --git a/docs/examples/account/create-recovery-otp.md b/docs/examples/account/create-recovery-otp.md new file mode 100644 index 00000000..06aff8ec --- /dev/null +++ b/docs/examples/account/create-recovery-otp.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_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.create_recovery_otp( + email: 'email@example.com', + phrase: false # optional +) +``` diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md index 3008032f..b7143c0c 100644 --- a/docs/examples/account/delete-sessions.md +++ b/docs/examples/account/delete-sessions.md @@ -10,5 +10,7 @@ client = Client.new account = Account.new(client) -result = account.delete_sessions() +result = account.delete_sessions( + current: false # optional +) ``` diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md index 47d2c033..5b810eb9 100644 --- a/docs/examples/account/list-sessions.md +++ b/docs/examples/account/list-sessions.md @@ -10,5 +10,7 @@ client = Client.new account = Account.new(client) -result = account.list_sessions() +result = account.list_sessions( + total: false # optional +) ``` diff --git a/docs/examples/account/update-email-verification-otp.md b/docs/examples/account/update-email-verification-otp.md new file mode 100644 index 00000000..dd20ac13 --- /dev/null +++ b/docs/examples/account/update-email-verification-otp.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_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.update_email_verification_otp( + user_id: '', + secret: '' +) +``` diff --git a/docs/examples/account/update-recovery-otp.md b/docs/examples/account/update-recovery-otp.md new file mode 100644 index 00000000..4376249c --- /dev/null +++ b/docs/examples/account/update-recovery-otp.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_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.update_recovery_otp( + user_id: '', + secret: '', + password: 'password' +) +``` diff --git a/docs/examples/avatars/delete-photo.md b/docs/examples/avatars/delete-photo.md new file mode 100644 index 00000000..87dadb8b --- /dev/null +++ b/docs/examples/avatars/delete-photo.md @@ -0,0 +1,14 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +avatars = Avatars.new(client) + +result = avatars.delete_photo() +``` diff --git a/docs/examples/avatars/update-photo.md b/docs/examples/avatars/update-photo.md new file mode 100644 index 00000000..221de406 --- /dev/null +++ b/docs/examples/avatars/update-photo.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_session('') # The user session to authenticate with + +avatars = Avatars.new(client) + +result = avatars.update_photo( + file: InputFile.from_path('dir/file.png') +) +``` diff --git a/docs/examples/databases/list-transactions.md b/docs/examples/databases/list-transactions.md index 9071982e..12daa7a1 100644 --- a/docs/examples/databases/list-transactions.md +++ b/docs/examples/databases/list-transactions.md @@ -11,6 +11,7 @@ client = Client.new databases = Databases.new(client) result = databases.list_transactions( - queries: [] # optional + queries: [], # optional + total: false # optional ) ``` diff --git a/docs/examples/documentsdb/list-transactions.md b/docs/examples/documentsdb/list-transactions.md index 82d368e1..2128e4f8 100644 --- a/docs/examples/documentsdb/list-transactions.md +++ b/docs/examples/documentsdb/list-transactions.md @@ -11,6 +11,7 @@ client = Client.new documents_db = DocumentsDB.new(client) result = documents_db.list_transactions( - queries: [] # optional + queries: [], # optional + total: false # optional ) ``` diff --git a/docs/examples/domains/create-preset-google-workspace.md b/docs/examples/domains/create-preset-google-workspace.md new file mode 100644 index 00000000..d81c279f --- /dev/null +++ b/docs/examples/domains/create-preset-google-workspace.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 + +domains = Domains.new(client) + +result = domains.create_preset_google_workspace( + domain_id: '' +) +``` diff --git a/docs/examples/domains/create-preset-i-cloud.md b/docs/examples/domains/create-preset-i-cloud.md new file mode 100644 index 00000000..531f3c5d --- /dev/null +++ b/docs/examples/domains/create-preset-i-cloud.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 + +domains = Domains.new(client) + +result = domains.create_preset_i_cloud( + domain_id: '' +) +``` diff --git a/docs/examples/domains/create-preset-mailgun.md b/docs/examples/domains/create-preset-mailgun.md new file mode 100644 index 00000000..2b39a5c3 --- /dev/null +++ b/docs/examples/domains/create-preset-mailgun.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 + +domains = Domains.new(client) + +result = domains.create_preset_mailgun( + domain_id: '' +) +``` diff --git a/docs/examples/domains/create-preset-outlook.md b/docs/examples/domains/create-preset-outlook.md new file mode 100644 index 00000000..e67b5857 --- /dev/null +++ b/docs/examples/domains/create-preset-outlook.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 + +domains = Domains.new(client) + +result = domains.create_preset_outlook( + domain_id: '' +) +``` diff --git a/docs/examples/domains/create-preset-proton-mail.md b/docs/examples/domains/create-preset-proton-mail.md new file mode 100644 index 00000000..ecbbecd6 --- /dev/null +++ b/docs/examples/domains/create-preset-proton-mail.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 + +domains = Domains.new(client) + +result = domains.create_preset_proton_mail( + domain_id: '' +) +``` diff --git a/docs/examples/domains/create-preset-zoho.md b/docs/examples/domains/create-preset-zoho.md new file mode 100644 index 00000000..d79be6e8 --- /dev/null +++ b/docs/examples/domains/create-preset-zoho.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 + +domains = Domains.new(client) + +result = domains.create_preset_zoho( + domain_id: '' +) +``` diff --git a/docs/examples/domains/create-record-a.md b/docs/examples/domains/create-record-a.md new file mode 100644 index 00000000..0d164ab4 --- /dev/null +++ b/docs/examples/domains/create-record-a.md @@ -0,0 +1,20 @@ +```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 + +domains = Domains.new(client) + +result = domains.create_record_a( + domain_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-aaaa.md b/docs/examples/domains/create-record-aaaa.md new file mode 100644 index 00000000..8dc59646 --- /dev/null +++ b/docs/examples/domains/create-record-aaaa.md @@ -0,0 +1,20 @@ +```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 + +domains = Domains.new(client) + +result = domains.create_record_aaaa( + domain_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-alias.md b/docs/examples/domains/create-record-alias.md new file mode 100644 index 00000000..fbb10b8f --- /dev/null +++ b/docs/examples/domains/create-record-alias.md @@ -0,0 +1,20 @@ +```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 + +domains = Domains.new(client) + +result = domains.create_record_alias( + domain_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-caa.md b/docs/examples/domains/create-record-caa.md new file mode 100644 index 00000000..5ec76857 --- /dev/null +++ b/docs/examples/domains/create-record-caa.md @@ -0,0 +1,20 @@ +```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 + +domains = Domains.new(client) + +result = domains.create_record_caa( + domain_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-cname.md b/docs/examples/domains/create-record-cname.md new file mode 100644 index 00000000..d5d81fb8 --- /dev/null +++ b/docs/examples/domains/create-record-cname.md @@ -0,0 +1,20 @@ +```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 + +domains = Domains.new(client) + +result = domains.create_record_cname( + domain_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-https.md b/docs/examples/domains/create-record-https.md new file mode 100644 index 00000000..54276b77 --- /dev/null +++ b/docs/examples/domains/create-record-https.md @@ -0,0 +1,20 @@ +```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 + +domains = Domains.new(client) + +result = domains.create_record_https( + domain_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-mx.md b/docs/examples/domains/create-record-mx.md new file mode 100644 index 00000000..41bc9c7d --- /dev/null +++ b/docs/examples/domains/create-record-mx.md @@ -0,0 +1,21 @@ +```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 + +domains = Domains.new(client) + +result = domains.create_record_mx( + domain_id: '', + name: '', + value: '', + ttl: 1, + priority: 0, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-ns.md b/docs/examples/domains/create-record-ns.md new file mode 100644 index 00000000..155d9040 --- /dev/null +++ b/docs/examples/domains/create-record-ns.md @@ -0,0 +1,20 @@ +```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 + +domains = Domains.new(client) + +result = domains.create_record_ns( + domain_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-srv.md b/docs/examples/domains/create-record-srv.md new file mode 100644 index 00000000..40f97aac --- /dev/null +++ b/docs/examples/domains/create-record-srv.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 + +domains = Domains.new(client) + +result = domains.create_record_srv( + domain_id: '', + name: '', + value: '', + ttl: 1, + priority: 0, + weight: 0, + port: 0, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-txt.md b/docs/examples/domains/create-record-txt.md new file mode 100644 index 00000000..01d9e6db --- /dev/null +++ b/docs/examples/domains/create-record-txt.md @@ -0,0 +1,20 @@ +```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 + +domains = Domains.new(client) + +result = domains.create_record_txt( + domain_id: '', + name: '', + ttl: 1, + value: '', # optional + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create.md b/docs/examples/domains/create.md new file mode 100644 index 00000000..765a5fba --- /dev/null +++ b/docs/examples/domains/create.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 + +domains = Domains.new(client) + +result = domains.create( + team_id: '', + domain: 'example.com' +) +``` diff --git a/docs/examples/domains/delete-record.md b/docs/examples/domains/delete-record.md new file mode 100644 index 00000000..8aafe5d5 --- /dev/null +++ b/docs/examples/domains/delete-record.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 + +domains = Domains.new(client) + +result = domains.delete_record( + domain_id: '', + record_id: '' +) +``` diff --git a/docs/examples/domains/delete.md b/docs/examples/domains/delete.md new file mode 100644 index 00000000..42520ee5 --- /dev/null +++ b/docs/examples/domains/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 + +domains = Domains.new(client) + +result = domains.delete( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-preset-google-workspace.md b/docs/examples/domains/get-preset-google-workspace.md new file mode 100644 index 00000000..42db938a --- /dev/null +++ b/docs/examples/domains/get-preset-google-workspace.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 + +domains = Domains.new(client) + +result = domains.get_preset_google_workspace( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-preset-i-cloud.md b/docs/examples/domains/get-preset-i-cloud.md new file mode 100644 index 00000000..35713afa --- /dev/null +++ b/docs/examples/domains/get-preset-i-cloud.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 + +domains = Domains.new(client) + +result = domains.get_preset_i_cloud( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-preset-mailgun.md b/docs/examples/domains/get-preset-mailgun.md new file mode 100644 index 00000000..82ad69fc --- /dev/null +++ b/docs/examples/domains/get-preset-mailgun.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 + +domains = Domains.new(client) + +result = domains.get_preset_mailgun( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-preset-outlook.md b/docs/examples/domains/get-preset-outlook.md new file mode 100644 index 00000000..887b514b --- /dev/null +++ b/docs/examples/domains/get-preset-outlook.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 + +domains = Domains.new(client) + +result = domains.get_preset_outlook( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-preset-proton-mail.md b/docs/examples/domains/get-preset-proton-mail.md new file mode 100644 index 00000000..01661d2d --- /dev/null +++ b/docs/examples/domains/get-preset-proton-mail.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 + +domains = Domains.new(client) + +result = domains.get_preset_proton_mail( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-preset-zoho.md b/docs/examples/domains/get-preset-zoho.md new file mode 100644 index 00000000..e5339dc1 --- /dev/null +++ b/docs/examples/domains/get-preset-zoho.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 + +domains = Domains.new(client) + +result = domains.get_preset_zoho( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-price.md b/docs/examples/domains/get-price.md new file mode 100644 index 00000000..4658fab8 --- /dev/null +++ b/docs/examples/domains/get-price.md @@ -0,0 +1,19 @@ +```ruby +require 'appwrite' + +include Appwrite +include Appwrite::Enums + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.get_price( + domain: 'example.com', + period_years: nil, # optional + registration_type: DomainRegistrationType::NEW # optional +) +``` diff --git a/docs/examples/domains/get-record.md b/docs/examples/domains/get-record.md new file mode 100644 index 00000000..2f55038a --- /dev/null +++ b/docs/examples/domains/get-record.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 + +domains = Domains.new(client) + +result = domains.get_record( + domain_id: '', + record_id: '' +) +``` diff --git a/docs/examples/domains/get-transfer-status.md b/docs/examples/domains/get-transfer-status.md new file mode 100644 index 00000000..e3b8b537 --- /dev/null +++ b/docs/examples/domains/get-transfer-status.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 + +domains = Domains.new(client) + +result = domains.get_transfer_status( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-zone.md b/docs/examples/domains/get-zone.md new file mode 100644 index 00000000..b3693663 --- /dev/null +++ b/docs/examples/domains/get-zone.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 + +domains = Domains.new(client) + +result = domains.get_zone( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get.md b/docs/examples/domains/get.md new file mode 100644 index 00000000..bca8160e --- /dev/null +++ b/docs/examples/domains/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 + +domains = Domains.new(client) + +result = domains.get( + domain_id: '' +) +``` diff --git a/docs/examples/domains/list-prices.md b/docs/examples/domains/list-prices.md new file mode 100644 index 00000000..a99450dc --- /dev/null +++ b/docs/examples/domains/list-prices.md @@ -0,0 +1,19 @@ +```ruby +require 'appwrite' + +include Appwrite +include Appwrite::Enums + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.list_prices( + domains: [], + period_years: nil, # optional + registration_type: DomainRegistrationType::NEW # optional +) +``` diff --git a/docs/examples/domains/list-records.md b/docs/examples/domains/list-records.md new file mode 100644 index 00000000..d25f19ad --- /dev/null +++ b/docs/examples/domains/list-records.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 + +domains = Domains.new(client) + +result = domains.list_records( + domain_id: '', + queries: [] # optional +) +``` diff --git a/docs/examples/domains/list.md b/docs/examples/domains/list.md new file mode 100644 index 00000000..44fcf339 --- /dev/null +++ b/docs/examples/domains/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 + +domains = Domains.new(client) + +result = domains.list( + queries: [], # optional + search: '' # optional +) +``` diff --git a/docs/examples/domains/update-nameservers.md b/docs/examples/domains/update-nameservers.md new file mode 100644 index 00000000..d6166825 --- /dev/null +++ b/docs/examples/domains/update-nameservers.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 + +domains = Domains.new(client) + +result = domains.update_nameservers( + domain_id: '', + nameservers: [] # optional +) +``` diff --git a/docs/examples/domains/update-record-a.md b/docs/examples/domains/update-record-a.md new file mode 100644 index 00000000..927597d1 --- /dev/null +++ b/docs/examples/domains/update-record-a.md @@ -0,0 +1,21 @@ +```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 + +domains = Domains.new(client) + +result = domains.update_record_a( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-aaaa.md b/docs/examples/domains/update-record-aaaa.md new file mode 100644 index 00000000..6d20866b --- /dev/null +++ b/docs/examples/domains/update-record-aaaa.md @@ -0,0 +1,21 @@ +```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 + +domains = Domains.new(client) + +result = domains.update_record_aaaa( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-alias.md b/docs/examples/domains/update-record-alias.md new file mode 100644 index 00000000..17558e8e --- /dev/null +++ b/docs/examples/domains/update-record-alias.md @@ -0,0 +1,21 @@ +```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 + +domains = Domains.new(client) + +result = domains.update_record_alias( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-caa.md b/docs/examples/domains/update-record-caa.md new file mode 100644 index 00000000..d77eec0f --- /dev/null +++ b/docs/examples/domains/update-record-caa.md @@ -0,0 +1,21 @@ +```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 + +domains = Domains.new(client) + +result = domains.update_record_caa( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-cname.md b/docs/examples/domains/update-record-cname.md new file mode 100644 index 00000000..3ec0aa0f --- /dev/null +++ b/docs/examples/domains/update-record-cname.md @@ -0,0 +1,21 @@ +```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 + +domains = Domains.new(client) + +result = domains.update_record_cname( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-https.md b/docs/examples/domains/update-record-https.md new file mode 100644 index 00000000..848a7c31 --- /dev/null +++ b/docs/examples/domains/update-record-https.md @@ -0,0 +1,21 @@ +```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 + +domains = Domains.new(client) + +result = domains.update_record_https( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-mx.md b/docs/examples/domains/update-record-mx.md new file mode 100644 index 00000000..4cf0cf8d --- /dev/null +++ b/docs/examples/domains/update-record-mx.md @@ -0,0 +1,22 @@ +```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 + +domains = Domains.new(client) + +result = domains.update_record_mx( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + priority: 0, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-ns.md b/docs/examples/domains/update-record-ns.md new file mode 100644 index 00000000..30974d70 --- /dev/null +++ b/docs/examples/domains/update-record-ns.md @@ -0,0 +1,21 @@ +```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 + +domains = Domains.new(client) + +result = domains.update_record_ns( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-srv.md b/docs/examples/domains/update-record-srv.md new file mode 100644 index 00000000..9b02cd69 --- /dev/null +++ b/docs/examples/domains/update-record-srv.md @@ -0,0 +1,24 @@ +```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 + +domains = Domains.new(client) + +result = domains.update_record_srv( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + priority: 0, + weight: 0, + port: 0, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-txt.md b/docs/examples/domains/update-record-txt.md new file mode 100644 index 00000000..89a777ed --- /dev/null +++ b/docs/examples/domains/update-record-txt.md @@ -0,0 +1,21 @@ +```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 + +domains = Domains.new(client) + +result = domains.update_record_txt( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-team.md b/docs/examples/domains/update-team.md new file mode 100644 index 00000000..03e4a81d --- /dev/null +++ b/docs/examples/domains/update-team.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 + +domains = Domains.new(client) + +result = domains.update_team( + domain_id: '', + team_id: '' +) +``` diff --git a/docs/examples/domains/update-zone.md b/docs/examples/domains/update-zone.md new file mode 100644 index 00000000..f7c145ee --- /dev/null +++ b/docs/examples/domains/update-zone.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 + +domains = Domains.new(client) + +result = domains.update_zone( + domain_id: '', + content: '' +) +``` diff --git a/docs/examples/domains/verify-nameservers.md b/docs/examples/domains/verify-nameservers.md new file mode 100644 index 00000000..cfbf8e3c --- /dev/null +++ b/docs/examples/domains/verify-nameservers.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 + +domains = Domains.new(client) + +result = domains.verify_nameservers( + domain_id: '' +) +``` diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md index 98a75466..99eecff4 100644 --- a/docs/examples/functions/list-runtimes.md +++ b/docs/examples/functions/list-runtimes.md @@ -10,5 +10,7 @@ client = Client.new functions = Functions.new(client) -result = functions.list_runtimes() +result = functions.list_runtimes( + total: false # optional +) ``` diff --git a/docs/examples/functions/list-specifications.md b/docs/examples/functions/list-specifications.md index 635f73a5..34f12bb0 100644 --- a/docs/examples/functions/list-specifications.md +++ b/docs/examples/functions/list-specifications.md @@ -11,6 +11,7 @@ client = Client.new functions = Functions.new(client) result = functions.list_specifications( - type: 'runtimes' # optional + type: 'runtimes', # optional + total: false # optional ) ``` diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md index cf31d3af..6935229a 100644 --- a/docs/examples/locale/list-codes.md +++ b/docs/examples/locale/list-codes.md @@ -10,5 +10,7 @@ client = Client.new locale = Locale.new(client) -result = locale.list_codes() +result = locale.list_codes( + total: false # optional +) ``` diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md index 1470c7d1..2e97e0b3 100644 --- a/docs/examples/locale/list-continents.md +++ b/docs/examples/locale/list-continents.md @@ -10,5 +10,7 @@ client = Client.new locale = Locale.new(client) -result = locale.list_continents() +result = locale.list_continents( + total: false # optional +) ``` diff --git a/docs/examples/locale/list-countries-eu.md b/docs/examples/locale/list-countries-eu.md index 7ca1e985..b54270b7 100644 --- a/docs/examples/locale/list-countries-eu.md +++ b/docs/examples/locale/list-countries-eu.md @@ -10,5 +10,7 @@ client = Client.new locale = Locale.new(client) -result = locale.list_countries_eu() +result = locale.list_countries_eu( + total: false # optional +) ``` diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md index 43c80c6a..de45f6b6 100644 --- a/docs/examples/locale/list-countries-phones.md +++ b/docs/examples/locale/list-countries-phones.md @@ -10,5 +10,7 @@ client = Client.new locale = Locale.new(client) -result = locale.list_countries_phones() +result = locale.list_countries_phones( + total: false # optional +) ``` diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md index a5a81c7b..a985d20b 100644 --- a/docs/examples/locale/list-countries.md +++ b/docs/examples/locale/list-countries.md @@ -10,5 +10,7 @@ client = Client.new locale = Locale.new(client) -result = locale.list_countries() +result = locale.list_countries( + total: false # optional +) ``` diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md index a5316f2b..2b698f1e 100644 --- a/docs/examples/locale/list-currencies.md +++ b/docs/examples/locale/list-currencies.md @@ -10,5 +10,7 @@ client = Client.new locale = Locale.new(client) -result = locale.list_currencies() +result = locale.list_currencies( + total: false # optional +) ``` diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md index 9c8655f4..8c0f1ae1 100644 --- a/docs/examples/locale/list-languages.md +++ b/docs/examples/locale/list-languages.md @@ -10,5 +10,7 @@ client = Client.new locale = Locale.new(client) -result = locale.list_languages() +result = locale.list_languages( + total: false # optional +) ``` diff --git a/docs/examples/messaging/create-appwrite-provider.md b/docs/examples/messaging/create-appwrite-provider.md new file mode 100644 index 00000000..ae56ec57 --- /dev/null +++ b/docs/examples/messaging/create-appwrite-provider.md @@ -0,0 +1,20 @@ +```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 + +messaging = Messaging.new(client) + +result = messaging.create_appwrite_provider( + provider_id: '', + name: '', + enabled: false, # optional + qos: 0, # optional + expiry: 0 # optional +) +``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index e661a8a3..1c89a59d 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -22,6 +22,8 @@ result = messaging.create_email( attachments: [], # optional draft: false, # optional html: false, # optional - scheduled_at: '2020-10-15T06:38:00.000+00:00' # optional + scheduled_at: '2020-10-15T06:38:00.000+00:00', # optional + reply_to_email: 'email@example.com', # optional + reply_to_name: '' # optional ) ``` diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index e94015e6..c1488a49 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -30,6 +30,7 @@ result = messaging.create_push( scheduled_at: '2020-10-15T06:38:00.000+00:00', # optional content_available: false, # optional critical: false, # optional - priority: MessagePriority::NORMAL # optional + priority: MessagePriority::NORMAL, # optional + channel_id: '' # optional ) ``` diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md index 85cc5d76..2b650e9f 100644 --- a/docs/examples/messaging/create-topic.md +++ b/docs/examples/messaging/create-topic.md @@ -13,6 +13,8 @@ messaging = Messaging.new(client) result = messaging.create_topic( topic_id: '', name: '', - subscribe: ["any"] # optional + subscribe: ["any"], # optional + qos: 0, # optional + expiry: 0 # optional ) ``` diff --git a/docs/examples/messaging/update-appwrite-provider.md b/docs/examples/messaging/update-appwrite-provider.md new file mode 100644 index 00000000..e35af727 --- /dev/null +++ b/docs/examples/messaging/update-appwrite-provider.md @@ -0,0 +1,20 @@ +```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 + +messaging = Messaging.new(client) + +result = messaging.update_appwrite_provider( + provider_id: '', + name: '', # optional + enabled: false, # optional + qos: 0, # optional + expiry: 0 # optional +) +``` diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index 727fdbc2..b0fb17ad 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -22,6 +22,8 @@ result = messaging.update_email( cc: [], # optional bcc: [], # optional scheduled_at: '2020-10-15T06:38:00.000+00:00', # optional - attachments: [] # optional + attachments: [], # optional + reply_to_email: 'email@example.com', # optional + reply_to_name: '' # optional ) ``` diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index 9aa0e8ba..a436395f 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -30,6 +30,7 @@ result = messaging.update_push( scheduled_at: '2020-10-15T06:38:00.000+00:00', # optional content_available: false, # optional critical: false, # optional - priority: MessagePriority::NORMAL # optional + priority: MessagePriority::NORMAL, # optional + channel_id: '' # optional ) ``` diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md index af1ed82f..43d8ce01 100644 --- a/docs/examples/messaging/update-topic.md +++ b/docs/examples/messaging/update-topic.md @@ -13,6 +13,8 @@ messaging = Messaging.new(client) result = messaging.update_topic( topic_id: '', name: '', # optional - subscribe: ["any"] # optional + subscribe: ["any"], # optional + qos: 0, # optional + expiry: 0 # optional ) ``` diff --git a/docs/examples/mongo/update.md b/docs/examples/mongo/update.md index 55f02acd..792e1e0d 100644 --- a/docs/examples/mongo/update.md +++ b/docs/examples/mongo/update.md @@ -25,7 +25,7 @@ result = mongo.update( storage_autoscaling: false, # optional storage_autoscaling_threshold_percent: 50, # optional storage_autoscaling_max_gb: 0, # optional - metrics_trace_sample_rate: null, # optional + metrics_trace_sample_rate: nil, # optional metrics_slow_query_log_threshold_ms: 0, # optional sql_api_enabled: false, # optional sql_api_allowed_statements: [], # optional diff --git a/docs/examples/mysql/update.md b/docs/examples/mysql/update.md index 2ba792ea..0d972eab 100644 --- a/docs/examples/mysql/update.md +++ b/docs/examples/mysql/update.md @@ -25,7 +25,7 @@ result = mysql.update( storage_autoscaling: false, # optional storage_autoscaling_threshold_percent: 50, # optional storage_autoscaling_max_gb: 0, # optional - metrics_trace_sample_rate: null, # optional + metrics_trace_sample_rate: nil, # optional metrics_slow_query_log_threshold_ms: 0, # optional sql_api_enabled: false, # optional sql_api_allowed_statements: [], # optional diff --git a/docs/examples/oauth2/introspect.md b/docs/examples/oauth2/introspect.md new file mode 100644 index 00000000..1ff23370 --- /dev/null +++ b/docs/examples/oauth2/introspect.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 + +oauth2 = Oauth2.new(client) + +result = oauth2.introspect( + token: '', + token_type_hint: 'access_token', # optional + client_id: '', # optional + client_secret: '' # optional +) +``` diff --git a/docs/examples/organization/create-ephemeral-project-key.md b/docs/examples/organization/create-ephemeral-project-key.md new file mode 100644 index 00000000..62814ac1 --- /dev/null +++ b/docs/examples/organization/create-ephemeral-project-key.md @@ -0,0 +1,19 @@ +```ruby +require 'appwrite' + +include Appwrite +include Appwrite::Enums + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +organization = Organization.new(client) + +result = organization.create_ephemeral_project_key( + project_id: '', + scopes: [ProjectKeyScopes::USERS_READ], + duration: 600 +) +``` diff --git a/docs/examples/organization/delete-project-key.md b/docs/examples/organization/delete-project-key.md new file mode 100644 index 00000000..f96b65e4 --- /dev/null +++ b/docs/examples/organization/delete-project-key.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 + +organization = Organization.new(client) + +result = organization.delete_project_key( + project_id: '', + key_id: '' +) +``` diff --git a/docs/examples/organization/get-project-key.md b/docs/examples/organization/get-project-key.md new file mode 100644 index 00000000..8270214d --- /dev/null +++ b/docs/examples/organization/get-project-key.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 + +organization = Organization.new(client) + +result = organization.get_project_key( + project_id: '', + key_id: '' +) +``` diff --git a/docs/examples/organization/list-project-keys.md b/docs/examples/organization/list-project-keys.md new file mode 100644 index 00000000..a2697641 --- /dev/null +++ b/docs/examples/organization/list-project-keys.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 + +organization = Organization.new(client) + +result = organization.list_project_keys( + project_id: '', + queries: [], # optional + total: false # optional +) +``` diff --git a/docs/examples/organization/update-project-key.md b/docs/examples/organization/update-project-key.md new file mode 100644 index 00000000..2908cae5 --- /dev/null +++ b/docs/examples/organization/update-project-key.md @@ -0,0 +1,21 @@ +```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 + +organization = Organization.new(client) + +result = organization.update_project_key( + project_id: '', + key_id: '', + name: '', + scopes: [ProjectKeyScopes::USERS_READ], + expire: '2020-10-15T06:38:00.000+00:00' # optional +) +``` diff --git a/docs/examples/postgresql/update.md b/docs/examples/postgresql/update.md index f43a9e88..48d76044 100644 --- a/docs/examples/postgresql/update.md +++ b/docs/examples/postgresql/update.md @@ -25,7 +25,7 @@ result = postgresql.update( storage_autoscaling: false, # optional storage_autoscaling_threshold_percent: 50, # optional storage_autoscaling_max_gb: 0, # optional - metrics_trace_sample_rate: null, # optional + metrics_trace_sample_rate: nil, # optional metrics_slow_query_log_threshold_ms: 0, # optional sql_api_enabled: false, # optional sql_api_allowed_statements: [], # optional diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md index 31c9725e..0caa3ca9 100644 --- a/docs/examples/project/create-android-platform.md +++ b/docs/examples/project/create-android-platform.md @@ -13,6 +13,7 @@ project = Project.new(client) result = project.create_android_platform( platform_id: '', name: '', - application_id: '' + application_id: '', + fingerprints: [] # optional ) ``` diff --git a/docs/examples/project/create-environment.md b/docs/examples/project/create-environment.md new file mode 100644 index 00000000..07f89149 --- /dev/null +++ b/docs/examples/project/create-environment.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.create_environment( + environment_id: '', + name: '' +) +``` diff --git a/docs/examples/project/delete-environment.md b/docs/examples/project/delete-environment.md new file mode 100644 index 00000000..5b1f39ad --- /dev/null +++ b/docs/examples/project/delete-environment.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_environment( + environment_id: '' +) +``` diff --git a/docs/examples/project/get-environment.md b/docs/examples/project/get-environment.md new file mode 100644 index 00000000..31bc3012 --- /dev/null +++ b/docs/examples/project/get-environment.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_environment( + environment_id: '' +) +``` diff --git a/docs/examples/project/list-environments.md b/docs/examples/project/list-environments.md new file mode 100644 index 00000000..83759521 --- /dev/null +++ b/docs/examples/project/list-environments.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_environments( + queries: [], # optional + total: false # optional +) +``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md index 07e177d2..827a321a 100644 --- a/docs/examples/project/update-android-platform.md +++ b/docs/examples/project/update-android-platform.md @@ -13,6 +13,7 @@ project = Project.new(client) result = project.update_android_platform( platform_id: '', name: '', - application_id: '' + application_id: '', + fingerprints: [] # optional ) ``` diff --git a/docs/examples/project/update-environment.md b/docs/examples/project/update-environment.md new file mode 100644 index 00000000..7f93137c --- /dev/null +++ b/docs/examples/project/update-environment.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.update_environment( + environment_id: '', + name: '' +) +``` diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md index adb2c8d6..884d4f09 100644 --- a/docs/examples/project/update-o-auth-2-apple.md +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -15,6 +15,8 @@ result = project.update_o_auth2_apple( key_id: '', # optional team_id: '', # optional p8_file: '', # optional - enabled: false # optional + enabled: false, # optional + native_client_ids: [], # optional + native_enabled: false # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md index e8d11dbf..17623091 100644 --- a/docs/examples/project/update-o-auth-2-auth-0.md +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -2,6 +2,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -14,6 +15,7 @@ result = project.update_o_auth2_auth0( client_id: '', # optional client_secret: '', # optional endpoint: '', # optional - enabled: false # optional + enabled: false, # optional + prompt: [ProjectOAuth2Auth0Prompt::NONE] # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md index 01bacd7c..3ef37b6a 100644 --- a/docs/examples/project/update-o-auth-2-discord.md +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -2,6 +2,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -13,6 +14,7 @@ project = Project.new(client) result = project.update_o_auth2_discord( client_id: '', # optional client_secret: '', # optional - enabled: false # optional + enabled: false, # optional + prompt: [ProjectOAuth2DiscordPrompt::NONE] # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md index e63370f7..b2546843 100644 --- a/docs/examples/project/update-o-auth-2-git-hub.md +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -2,6 +2,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -13,6 +14,7 @@ project = Project.new(client) result = project.update_o_auth2_git_hub( client_id: '', # optional client_secret: '', # optional - enabled: false # optional + enabled: false, # optional + prompt: [ProjectOAuth2GitHubPrompt::SELECT_ACCOUNT] # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md index be38c0f3..16c1c992 100644 --- a/docs/examples/project/update-o-auth-2-google.md +++ b/docs/examples/project/update-o-auth-2-google.md @@ -15,6 +15,8 @@ result = project.update_o_auth2_google( client_id: '', # optional client_secret: '', # optional prompt: [ProjectOAuth2GooglePrompt::NONE], # optional - enabled: false # optional + enabled: false, # optional + native_client_ids: [], # optional + native_enabled: false # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md new file mode 100644 index 00000000..035810f7 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-kakao.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_o_auth2_kakao( + client_id: '', # optional + client_secret: '', # optional + prompt: [ProjectOAuth2KakaoPrompt::NONE], # optional + enabled: false # optional +) +``` diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md index 0a5563f7..77262e2a 100644 --- a/docs/examples/project/update-o-auth-2-microsoft.md +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -2,6 +2,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -14,6 +15,7 @@ result = project.update_o_auth2_microsoft( application_id: '', # optional application_secret: '', # optional tenant: '', # optional - enabled: false # optional + enabled: false, # optional + prompt: [ProjectOAuth2MicrosoftPrompt::NONE] # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md index 44716551..f421c98e 100644 --- a/docs/examples/project/update-o-auth-2-okta.md +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -2,6 +2,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -15,6 +16,7 @@ result = project.update_o_auth2_okta( client_secret: '', # optional domain: 'example.com', # optional authorization_server_id: '', # optional - enabled: false # optional + enabled: false, # optional + prompt: [ProjectOAuth2OktaPrompt::NONE] # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md index f573693f..a6bd4013 100644 --- a/docs/examples/project/update-o-auth-2-salesforce.md +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -2,6 +2,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -13,6 +14,7 @@ project = Project.new(client) result = project.update_o_auth2_salesforce( customer_key: '', # optional customer_secret: '', # optional - enabled: false # optional + enabled: false, # optional + prompt: [ProjectOAuth2SalesforcePrompt::LOGIN] # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-tik-tok.md b/docs/examples/project/update-o-auth-2-tik-tok.md new file mode 100644 index 00000000..36b8ceea --- /dev/null +++ b/docs/examples/project/update-o-auth-2-tik-tok.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_o_auth2_tik_tok( + client_id: '', # optional + client_secret: '', # optional + enabled: false # optional +) +``` diff --git a/docs/examples/project/update-o-auth-2-webflow.md b/docs/examples/project/update-o-auth-2-webflow.md new file mode 100644 index 00000000..22b17c71 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-webflow.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_o_auth2_webflow( + client_id: '', # optional + client_secret: '', # optional + enabled: false # optional +) +``` diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md index 2fbd5fed..db6aec11 100644 --- a/docs/examples/project/update-o-auth-2-zoho.md +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -2,6 +2,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -13,6 +14,7 @@ project = Project.new(client) result = project.update_o_auth2_zoho( client_id: '', # optional client_secret: '', # optional - enabled: false # optional + enabled: false, # optional + prompt: [ProjectOAuth2ZohoPrompt::CONSENT] # optional ) ``` diff --git a/docs/examples/project/update-password-pwned-policy.md b/docs/examples/project/update-password-pwned-policy.md new file mode 100644 index 00000000..abb2abb6 --- /dev/null +++ b/docs/examples/project/update-password-pwned-policy.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_password_pwned_policy( + enabled: false, # optional + sessions: false, # optional + users: false # optional +) +``` diff --git a/docs/examples/project/update-password-rotation-policy.md b/docs/examples/project/update-password-rotation-policy.md new file mode 100644 index 00000000..d337bed6 --- /dev/null +++ b/docs/examples/project/update-password-rotation-policy.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.update_password_rotation_policy( + enabled: false, # optional + max_age: 86400 # optional +) +``` diff --git a/docs/examples/sites/list-frameworks.md b/docs/examples/sites/list-frameworks.md index a33303a2..7b8b8f56 100644 --- a/docs/examples/sites/list-frameworks.md +++ b/docs/examples/sites/list-frameworks.md @@ -10,5 +10,7 @@ client = Client.new sites = Sites.new(client) -result = sites.list_frameworks() +result = sites.list_frameworks( + total: false # optional +) ``` diff --git a/docs/examples/sites/list-specifications.md b/docs/examples/sites/list-specifications.md index 9ed8d001..1f816b90 100644 --- a/docs/examples/sites/list-specifications.md +++ b/docs/examples/sites/list-specifications.md @@ -11,6 +11,7 @@ client = Client.new sites = Sites.new(client) result = sites.list_specifications( - type: 'runtimes' # optional + type: 'runtimes', # optional + total: false # optional ) ``` diff --git a/docs/examples/tablesdb/list-transactions.md b/docs/examples/tablesdb/list-transactions.md index f8800dd7..de6a2389 100644 --- a/docs/examples/tablesdb/list-transactions.md +++ b/docs/examples/tablesdb/list-transactions.md @@ -11,6 +11,7 @@ client = Client.new tables_db = TablesDB.new(client) result = tables_db.list_transactions( - queries: [] # optional + queries: [], # optional + total: false # optional ) ``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 7df704e7..c90a80d6 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -17,6 +17,7 @@ result = teams.create_membership( user_id: '', # optional phone: '+12065550100', # optional url: 'https://example.com', # optional - name: '' # optional + name: '', # optional + membership_id: '' # optional ) ``` diff --git a/docs/examples/vectorsdb/list-transactions.md b/docs/examples/vectorsdb/list-transactions.md index 9c2182da..2db8f34b 100644 --- a/docs/examples/vectorsdb/list-transactions.md +++ b/docs/examples/vectorsdb/list-transactions.md @@ -11,6 +11,7 @@ client = Client.new vectors_db = VectorsDB.new(client) result = vectors_db.list_transactions( - queries: [] # optional + queries: [], # optional + total: false # optional ) ``` diff --git a/docs/examples/waf/create-bypass-rule.md b/docs/examples/waf/create-bypass-rule.md new file mode 100644 index 00000000..084ce800 --- /dev/null +++ b/docs/examples/waf/create-bypass-rule.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 + +waf = Waf.new(client) + +result = waf.create_bypass_rule( + rule_id: '', + resource_type: 'api', + name: '', + resource_id: '', # optional + description: '', # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # optional +) +``` diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md new file mode 100644 index 00000000..cc4545ec --- /dev/null +++ b/docs/examples/waf/create-challenge-rule.md @@ -0,0 +1,26 @@ +```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 + +waf = Waf.new(client) + +result = waf.create_challenge_rule( + rule_id: '', + resource_type: 'api', + name: '', + resource_id: '', # optional + description: '', # optional + challenge_type: 'compute', # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [], # optional + difficulty: 1, # optional + ttl: 900 # optional +) +``` diff --git a/docs/examples/waf/create-deny-rule.md b/docs/examples/waf/create-deny-rule.md new file mode 100644 index 00000000..653f3786 --- /dev/null +++ b/docs/examples/waf/create-deny-rule.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 + +waf = Waf.new(client) + +result = waf.create_deny_rule( + rule_id: '', + resource_type: 'api', + name: '', + resource_id: '', # optional + description: '', # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # optional +) +``` diff --git a/docs/examples/waf/create-rate-limit-rule.md b/docs/examples/waf/create-rate-limit-rule.md new file mode 100644 index 00000000..6b188b9f --- /dev/null +++ b/docs/examples/waf/create-rate-limit-rule.md @@ -0,0 +1,28 @@ +```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 + +waf = Waf.new(client) + +result = waf.create_rate_limit_rule( + rule_id: '', + resource_type: 'api', + name: '', + limit: 1, + interval: 1, + resource_id: '', # optional + description: '', # optional + key: 'ip', # optional + strategy: 'fixedWindow', # optional + max_bucket_size: 1, # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # optional +) +``` diff --git a/docs/examples/waf/create-redirect-rule.md b/docs/examples/waf/create-redirect-rule.md new file mode 100644 index 00000000..ffa441bb --- /dev/null +++ b/docs/examples/waf/create-redirect-rule.md @@ -0,0 +1,25 @@ +```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 + +waf = Waf.new(client) + +result = waf.create_redirect_rule( + rule_id: '', + resource_type: 'api', + name: '', + location: '', + status_code: 300, + resource_id: '', # optional + description: '', # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # optional +) +``` diff --git a/docs/examples/waf/delete-rule.md b/docs/examples/waf/delete-rule.md new file mode 100644 index 00000000..6f1bb035 --- /dev/null +++ b/docs/examples/waf/delete-rule.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 + +waf = Waf.new(client) + +result = waf.delete_rule( + rule_id: '' +) +``` diff --git a/docs/examples/waf/get-rule.md b/docs/examples/waf/get-rule.md new file mode 100644 index 00000000..c6929bf8 --- /dev/null +++ b/docs/examples/waf/get-rule.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 + +waf = Waf.new(client) + +result = waf.get_rule( + rule_id: '' +) +``` diff --git a/docs/examples/waf/list-rules.md b/docs/examples/waf/list-rules.md new file mode 100644 index 00000000..3c925cc9 --- /dev/null +++ b/docs/examples/waf/list-rules.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 + +waf = Waf.new(client) + +result = waf.list_rules( + queries: [], # optional + search: '', # optional + total: false # optional +) +``` diff --git a/docs/examples/waf/update-bypass-rule.md b/docs/examples/waf/update-bypass-rule.md new file mode 100644 index 00000000..8e691de2 --- /dev/null +++ b/docs/examples/waf/update-bypass-rule.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 + +waf = Waf.new(client) + +result = waf.update_bypass_rule( + rule_id: '', + resource_type: 'api', # optional + resource_id: '', # optional + name: '', # optional + description: '', # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # optional +) +``` diff --git a/docs/examples/waf/update-challenge-rule.md b/docs/examples/waf/update-challenge-rule.md new file mode 100644 index 00000000..19b117fe --- /dev/null +++ b/docs/examples/waf/update-challenge-rule.md @@ -0,0 +1,26 @@ +```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 + +waf = Waf.new(client) + +result = waf.update_challenge_rule( + rule_id: '', + resource_type: 'api', # optional + resource_id: '', # optional + name: '', # optional + description: '', # optional + challenge_type: 'compute', # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [], # optional + difficulty: 1, # optional + ttl: 900 # optional +) +``` diff --git a/docs/examples/waf/update-deny-rule.md b/docs/examples/waf/update-deny-rule.md new file mode 100644 index 00000000..f623be16 --- /dev/null +++ b/docs/examples/waf/update-deny-rule.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 + +waf = Waf.new(client) + +result = waf.update_deny_rule( + rule_id: '', + resource_type: 'api', # optional + resource_id: '', # optional + name: '', # optional + description: '', # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # optional +) +``` diff --git a/docs/examples/waf/update-rate-limit-rule.md b/docs/examples/waf/update-rate-limit-rule.md new file mode 100644 index 00000000..2eb58465 --- /dev/null +++ b/docs/examples/waf/update-rate-limit-rule.md @@ -0,0 +1,27 @@ +```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 + +waf = Waf.new(client) + +result = waf.update_rate_limit_rule( + rule_id: '', + resource_type: 'api', # optional + resource_id: '', # optional + name: '', # optional + description: '', # optional + limit: 1, # optional + interval: 1, # optional + key: 'ip', # optional + max_bucket_size: 1, # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # optional +) +``` diff --git a/docs/examples/waf/update-redirect-rule.md b/docs/examples/waf/update-redirect-rule.md new file mode 100644 index 00000000..3ebfef30 --- /dev/null +++ b/docs/examples/waf/update-redirect-rule.md @@ -0,0 +1,25 @@ +```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 + +waf = Waf.new(client) + +result = waf.update_redirect_rule( + rule_id: '', + resource_type: 'api', # optional + resource_id: '', # optional + name: '', # optional + description: '', # optional + location: '', # optional + status_code: 300, # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # optional +) +``` diff --git a/lib/appwrite.rb b/lib/appwrite.rb index 69ee8569..7cf6053d 100644 --- a/lib/appwrite.rb +++ b/lib/appwrite.rb @@ -120,6 +120,7 @@ require_relative 'appwrite/models/algo_scrypt' require_relative 'appwrite/models/algo_scrypt_modified' require_relative 'appwrite/models/algo_argon2' +require_relative 'appwrite/models/account' require_relative 'appwrite/models/preferences' require_relative 'appwrite/models/session' require_relative 'appwrite/models/identity' @@ -163,6 +164,7 @@ require_relative 'appwrite/models/o_auth2_yandex' require_relative 'appwrite/models/o_auth2_x' require_relative 'appwrite/models/o_auth2_word_press' +require_relative 'appwrite/models/o_auth2_webflow' require_relative 'appwrite/models/o_auth2_twitch' require_relative 'appwrite/models/o_auth2_stripe' require_relative 'appwrite/models/o_auth2_spotify' @@ -192,11 +194,15 @@ require_relative 'appwrite/models/o_auth2_apple' require_relative 'appwrite/models/o_auth2_microsoft' require_relative 'appwrite/models/o_auth2_resend' +require_relative 'appwrite/models/o_auth2_tik_tok' +require_relative 'appwrite/models/o_auth2_kakao' require_relative 'appwrite/models/o_auth2_provider_list' require_relative 'appwrite/models/policy_password_dictionary' require_relative 'appwrite/models/policy_password_history' require_relative 'appwrite/models/policy_password_strength' require_relative 'appwrite/models/policy_password_personal_data' +require_relative 'appwrite/models/policy_password_pwned' +require_relative 'appwrite/models/policy_password_rotation' require_relative 'appwrite/models/policy_session_alert' require_relative 'appwrite/models/policy_session_duration' require_relative 'appwrite/models/policy_session_invalidation' @@ -261,6 +267,10 @@ require_relative 'appwrite/models/dedicated_database_execution_column' require_relative 'appwrite/models/dedicated_database_restoration' require_relative 'appwrite/models/database_status' +require_relative 'appwrite/models/dns_record' +require_relative 'appwrite/models/domain' +require_relative 'appwrite/models/domain_price' +require_relative 'appwrite/models/domain_transfer_status' require_relative 'appwrite/models/dedicated_database_extensions' require_relative 'appwrite/models/dedicated_database_member' require_relative 'appwrite/models/dedicated_database_operation' @@ -299,8 +309,15 @@ require_relative 'appwrite/models/oauth2_device_authorization' require_relative 'appwrite/models/oauth2_par' require_relative 'appwrite/models/oauth2_token' +require_relative 'appwrite/models/oauth2_introspection' require_relative 'appwrite/models/oauth2_consent' require_relative 'appwrite/models/oauth2_consent_token' +require_relative 'appwrite/models/waf_rule_bypass' +require_relative 'appwrite/models/waf_rule_deny' +require_relative 'appwrite/models/waf_rule_challenge' +require_relative 'appwrite/models/waf_rule_rate_limit' +require_relative 'appwrite/models/waf_rule_redirect' +require_relative 'appwrite/models/waf_rule_list' require_relative 'appwrite/models/oauth2_project' require_relative 'appwrite/models/oauth2_organization' require_relative 'appwrite/models/oauth2_project_list' @@ -313,6 +330,9 @@ require_relative 'appwrite/models/backup_restoration_list' require_relative 'appwrite/models/database_migration_list' require_relative 'appwrite/models/dedicated_database_list' +require_relative 'appwrite/models/dns_records_list' +require_relative 'appwrite/models/domain_prices_list' +require_relative 'appwrite/models/domains_list' require_relative 'appwrite/models/apps_list' require_relative 'appwrite/models/app_secret_list' require_relative 'appwrite/models/app_scope_list' @@ -321,6 +341,7 @@ require_relative 'appwrite/enums/authenticator_type' require_relative 'appwrite/enums/authentication_factor' +require_relative 'appwrite/enums/id_token_provider' require_relative 'appwrite/enums/o_auth_provider' require_relative 'appwrite/enums/browser' require_relative 'appwrite/enums/credit_card' @@ -335,6 +356,7 @@ require_relative 'appwrite/enums/databases_index_type' require_relative 'appwrite/enums/order_by' require_relative 'appwrite/enums/documents_db_index_type' +require_relative 'appwrite/enums/domain_registration_type' require_relative 'appwrite/enums/embedding_model' require_relative 'appwrite/enums/runtime' require_relative 'appwrite/enums/project_key_scopes' @@ -347,8 +369,16 @@ require_relative 'appwrite/enums/organization_key_scopes' require_relative 'appwrite/enums/region' require_relative 'appwrite/enums/project_auth_method_id' +require_relative 'appwrite/enums/project_o_auth2_auth0_prompt' +require_relative 'appwrite/enums/project_o_auth2_discord_prompt' +require_relative 'appwrite/enums/project_o_auth2_git_hub_prompt' require_relative 'appwrite/enums/project_o_auth2_google_prompt' +require_relative 'appwrite/enums/project_o_auth2_kakao_prompt' +require_relative 'appwrite/enums/project_o_auth2_microsoft_prompt' require_relative 'appwrite/enums/project_o_auth2_oidc_prompt' +require_relative 'appwrite/enums/project_o_auth2_okta_prompt' +require_relative 'appwrite/enums/project_o_auth2_salesforce_prompt' +require_relative 'appwrite/enums/project_o_auth2_zoho_prompt' require_relative 'appwrite/enums/project_o_auth_provider_id' require_relative 'appwrite/enums/project_policy_id' require_relative 'appwrite/enums/project_protocol_id' @@ -377,13 +407,23 @@ require_relative 'appwrite/enums/execution_resource_type' require_relative 'appwrite/enums/execution_trigger' require_relative 'appwrite/enums/execution_status' +require_relative 'appwrite/enums/o_auth2_github_prompt' +require_relative 'appwrite/enums/o_auth2_discord_prompt' require_relative 'appwrite/enums/o_auth2_google_prompt' +require_relative 'appwrite/enums/o_auth2_zoho_prompt' +require_relative 'appwrite/enums/o_auth2_salesforce_prompt' +require_relative 'appwrite/enums/o_auth2_auth0_prompt' require_relative 'appwrite/enums/o_auth2_oidc_prompt' +require_relative 'appwrite/enums/o_auth2_okta_prompt' +require_relative 'appwrite/enums/o_auth2_microsoft_prompt' +require_relative 'appwrite/enums/o_auth2_kakao_prompt' require_relative 'appwrite/enums/platform_type' require_relative 'appwrite/enums/proxy_rule_deployment_resource_type' require_relative 'appwrite/enums/proxy_rule_status' require_relative 'appwrite/enums/message_status' require_relative 'appwrite/enums/billing_plan_group' +require_relative 'appwrite/enums/domain_transfer_status_enum' +require_relative 'appwrite/enums/waf_rule_action' require_relative 'appwrite/services/account' require_relative 'appwrite/services/activities' @@ -392,6 +432,7 @@ require_relative 'appwrite/services/backups' require_relative 'appwrite/services/databases' require_relative 'appwrite/services/documents_db' +require_relative 'appwrite/services/domains' require_relative 'appwrite/services/embeddings' require_relative 'appwrite/services/functions' require_relative 'appwrite/services/graphql' @@ -413,4 +454,5 @@ require_relative 'appwrite/services/tokens' require_relative 'appwrite/services/users' require_relative 'appwrite/services/vectors_db' +require_relative 'appwrite/services/waf' require_relative 'appwrite/services/webhooks' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index 67541fca..99f8f563 100644 --- a/lib/appwrite/client.rb +++ b/lib/appwrite/client.rb @@ -14,7 +14,7 @@ def initialize 'x-sdk-name' => 'Ruby', 'x-sdk-platform' => 'server', 'x-sdk-language' => 'ruby', - 'x-sdk-version' => '28.3.2', + 'x-sdk-version' => '28.4.0', 'X-Appwrite-Response-Format' => '2.0.0' } @endpoint = 'https://cloud.appwrite.io/v1' @@ -278,7 +278,8 @@ def chunked_upload( param_name: '', id_param_name: nil, on_progress: nil, - response_type: nil + response_type: nil, + method: 'POST' ) input_file = params[param_name.to_sym] @@ -295,7 +296,7 @@ def chunked_upload( end params[param_name.to_sym] = input_file return call( - method: 'POST', + method: method, path: path, headers: headers, params: params, @@ -359,7 +360,7 @@ def chunked_upload( chunk_headers['x-appwrite-id'] = current_upload_id if current_upload_id call( - method: 'POST', + method: method, path: path, headers: chunk_headers, params: chunk_params, @@ -520,6 +521,10 @@ def fetch( raise Appwrite::Exception.new(response.body, response.code, response, response.body) end + if response_type == "text" + return decode_text(response) + end + if response.respond_to?("body_permitted?") return response.body if response.body_permitted? end @@ -527,6 +532,17 @@ def fetch( return response end + def decode_text(response) + charset = response.type_params['charset'] || 'utf-8' + encoding = begin + Encoding.find(charset) + rescue ArgumentError + Encoding::UTF_8 + end + + String.new(response.body.to_s, encoding: encoding).encode(Encoding::UTF_8) + end + def encode_form_data(value, key = nil) case value when Hash diff --git a/lib/appwrite/enums/billing_plan_group.rb b/lib/appwrite/enums/billing_plan_group.rb index 343b49a8..1f3ca3cf 100644 --- a/lib/appwrite/enums/billing_plan_group.rb +++ b/lib/appwrite/enums/billing_plan_group.rb @@ -2,6 +2,8 @@ module Appwrite module Enums module BillingPlanGroup STARTER = 'starter' + FREE = 'free' + START = 'start' PRO = 'pro' SCALE = 'scale' end diff --git a/lib/appwrite/enums/build_runtime.rb b/lib/appwrite/enums/build_runtime.rb index 0f1a8803..cb868c9c 100644 --- a/lib/appwrite/enums/build_runtime.rb +++ b/lib/appwrite/enums/build_runtime.rb @@ -52,6 +52,7 @@ module BuildRuntime DART_3_10 = 'dart-3.10' DART_3_11 = 'dart-3.11' DART_3_12 = 'dart-3.12' + DART_3_13 = 'dart-3.13' DOTNET_6_0 = 'dotnet-6.0' DOTNET_7_0 = 'dotnet-7.0' DOTNET_8_0 = 'dotnet-8.0' @@ -94,6 +95,7 @@ module BuildRuntime FLUTTER_3_38 = 'flutter-3.38' FLUTTER_3_41 = 'flutter-3.41' FLUTTER_3_44 = 'flutter-3.44' + FLUTTER_3_47 = 'flutter-3.47' end end end diff --git a/lib/appwrite/enums/databases_index_type.rb b/lib/appwrite/enums/databases_index_type.rb index 0dd80acc..ea0dd24d 100644 --- a/lib/appwrite/enums/databases_index_type.rb +++ b/lib/appwrite/enums/databases_index_type.rb @@ -5,6 +5,7 @@ module DatabasesIndexType FULLTEXT = 'fulltext' UNIQUE = 'unique' SPATIAL = 'spatial' + TRIGRAM = 'trigram' end end end diff --git a/lib/appwrite/enums/domain_registration_type.rb b/lib/appwrite/enums/domain_registration_type.rb new file mode 100644 index 00000000..81869b83 --- /dev/null +++ b/lib/appwrite/enums/domain_registration_type.rb @@ -0,0 +1,10 @@ +module Appwrite + module Enums + module DomainRegistrationType + NEW = 'new' + TRANSFER = 'transfer' + RENEWAL = 'renewal' + TRADE = 'trade' + end + end +end diff --git a/lib/appwrite/enums/domain_transfer_status_enum.rb b/lib/appwrite/enums/domain_transfer_status_enum.rb new file mode 100644 index 00000000..99eeb20d --- /dev/null +++ b/lib/appwrite/enums/domain_transfer_status_enum.rb @@ -0,0 +1,14 @@ +module Appwrite + module Enums + module DomainTransferStatusEnum + TRANSFERRABLE = 'transferrable' + NOT_TRANSFERRABLE = 'not_transferrable' + PENDING_OWNER = 'pending_owner' + PENDING_ADMIN = 'pending_admin' + PENDING_REGISTRY = 'pending_registry' + COMPLETED = 'completed' + CANCELLED = 'cancelled' + SERVICE_UNAVAILABLE = 'service_unavailable' + end + end +end diff --git a/lib/appwrite/enums/framework.rb b/lib/appwrite/enums/framework.rb index 6beab64f..bc51bd04 100644 --- a/lib/appwrite/enums/framework.rb +++ b/lib/appwrite/enums/framework.rb @@ -13,6 +13,7 @@ module Framework REMIX = 'remix' LYNX = 'lynx' FLUTTER = 'flutter' + JASPR = 'jaspr' REACT_NATIVE = 'react-native' VITE = 'vite' OTHER = 'other' diff --git a/lib/appwrite/enums/id_token_provider.rb b/lib/appwrite/enums/id_token_provider.rb new file mode 100644 index 00000000..8513d5b0 --- /dev/null +++ b/lib/appwrite/enums/id_token_provider.rb @@ -0,0 +1,8 @@ +module Appwrite + module Enums + module IdTokenProvider + APPLE = 'apple' + GOOGLE = 'google' + end + end +end diff --git a/lib/appwrite/enums/image_gravity.rb b/lib/appwrite/enums/image_gravity.rb index 6eb0b5b1..705778a4 100644 --- a/lib/appwrite/enums/image_gravity.rb +++ b/lib/appwrite/enums/image_gravity.rb @@ -1,6 +1,7 @@ module Appwrite module Enums module ImageGravity + AUTO = 'auto' CENTER = 'center' TOP_LEFT = 'top-left' TOP = 'top' diff --git a/lib/appwrite/enums/o_auth2_auth0_prompt.rb b/lib/appwrite/enums/o_auth2_auth0_prompt.rb new file mode 100644 index 00000000..e53dde5b --- /dev/null +++ b/lib/appwrite/enums/o_auth2_auth0_prompt.rb @@ -0,0 +1,9 @@ +module Appwrite + module Enums + module OAuth2Auth0Prompt + NONE = 'none' + LOGIN = 'login' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/o_auth2_discord_prompt.rb b/lib/appwrite/enums/o_auth2_discord_prompt.rb new file mode 100644 index 00000000..87d52730 --- /dev/null +++ b/lib/appwrite/enums/o_auth2_discord_prompt.rb @@ -0,0 +1,8 @@ +module Appwrite + module Enums + module OAuth2DiscordPrompt + NONE = 'none' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/o_auth2_github_prompt.rb b/lib/appwrite/enums/o_auth2_github_prompt.rb new file mode 100644 index 00000000..8c662b16 --- /dev/null +++ b/lib/appwrite/enums/o_auth2_github_prompt.rb @@ -0,0 +1,7 @@ +module Appwrite + module Enums + module OAuth2GithubPrompt + SELECT_ACCOUNT = 'select_account' + end + end +end diff --git a/lib/appwrite/enums/o_auth2_kakao_prompt.rb b/lib/appwrite/enums/o_auth2_kakao_prompt.rb new file mode 100644 index 00000000..a4597c3d --- /dev/null +++ b/lib/appwrite/enums/o_auth2_kakao_prompt.rb @@ -0,0 +1,10 @@ +module Appwrite + module Enums + module OAuth2KakaoPrompt + NONE = 'none' + LOGIN = 'login' + CREATE = 'create' + SELECT_ACCOUNT = 'select_account' + end + end +end diff --git a/lib/appwrite/enums/o_auth2_microsoft_prompt.rb b/lib/appwrite/enums/o_auth2_microsoft_prompt.rb new file mode 100644 index 00000000..24e04c48 --- /dev/null +++ b/lib/appwrite/enums/o_auth2_microsoft_prompt.rb @@ -0,0 +1,10 @@ +module Appwrite + module Enums + module OAuth2MicrosoftPrompt + NONE = 'none' + LOGIN = 'login' + CONSENT = 'consent' + SELECT_ACCOUNT = 'select_account' + end + end +end diff --git a/lib/appwrite/enums/o_auth2_okta_prompt.rb b/lib/appwrite/enums/o_auth2_okta_prompt.rb new file mode 100644 index 00000000..773af5e9 --- /dev/null +++ b/lib/appwrite/enums/o_auth2_okta_prompt.rb @@ -0,0 +1,9 @@ +module Appwrite + module Enums + module OAuth2OktaPrompt + NONE = 'none' + LOGIN = 'login' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/o_auth2_salesforce_prompt.rb b/lib/appwrite/enums/o_auth2_salesforce_prompt.rb new file mode 100644 index 00000000..9ffba0ed --- /dev/null +++ b/lib/appwrite/enums/o_auth2_salesforce_prompt.rb @@ -0,0 +1,8 @@ +module Appwrite + module Enums + module OAuth2SalesforcePrompt + LOGIN = 'login' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/o_auth2_zoho_prompt.rb b/lib/appwrite/enums/o_auth2_zoho_prompt.rb new file mode 100644 index 00000000..88cabea6 --- /dev/null +++ b/lib/appwrite/enums/o_auth2_zoho_prompt.rb @@ -0,0 +1,7 @@ +module Appwrite + module Enums + module OAuth2ZohoPrompt + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/o_auth_provider.rb b/lib/appwrite/enums/o_auth_provider.rb index 13025937..27c112c6 100644 --- a/lib/appwrite/enums/o_auth_provider.rb +++ b/lib/appwrite/enums/o_auth_provider.rb @@ -23,6 +23,7 @@ module OAuthProvider GITLAB = 'gitlab' GOOGLE = 'google' HUGGINGFACE = 'huggingface' + KAKAO = 'kakao' KEYCLOAK = 'keycloak' KICK = 'kick' LINKEDIN = 'linkedin' @@ -38,9 +39,11 @@ module OAuthProvider SLACK = 'slack' SPOTIFY = 'spotify' STRIPE = 'stripe' + TIKTOK = 'tiktok' TRADESHIFT = 'tradeshift' TRADESHIFTBOX = 'tradeshiftBox' TWITCH = 'twitch' + WEBFLOW = 'webflow' WORDPRESS = 'wordpress' X = 'x' YAHOO = 'yahoo' diff --git a/lib/appwrite/enums/project_email_template_id.rb b/lib/appwrite/enums/project_email_template_id.rb index bfe21974..525eaabf 100644 --- a/lib/appwrite/enums/project_email_template_id.rb +++ b/lib/appwrite/enums/project_email_template_id.rb @@ -8,6 +8,8 @@ module ProjectEmailTemplateId MFACHALLENGE = 'mfaChallenge' SESSIONALERT = 'sessionAlert' OTPSESSION = 'otpSession' + OTPVERIFICATION = 'otpVerification' + OTPRECOVERY = 'otpRecovery' end end end diff --git a/lib/appwrite/enums/project_key_scopes.rb b/lib/appwrite/enums/project_key_scopes.rb index 388f0004..2a30d3a3 100644 --- a/lib/appwrite/enums/project_key_scopes.rb +++ b/lib/appwrite/enums/project_key_scopes.rb @@ -91,6 +91,7 @@ module ProjectKeyScopes WEBHOOKS_WRITE = 'webhooks.write' LOCALE_READ = 'locale.read' AVATARS_READ = 'avatars.read' + AVATARS_WRITE = 'avatars.write' HEALTH_READ = 'health.read' ASSISTANT_READ = 'assistant.read' MIGRATIONS_READ = 'migrations.read' @@ -105,6 +106,7 @@ module ProjectKeyScopes REPORTS_WRITE = 'reports.write' PRESENCES_READ = 'presences.read' PRESENCES_WRITE = 'presences.write' + DEDICATEDDATABASES_EXECUTE = 'dedicatedDatabases.execute' BACKUPS_POLICIES_READ = 'backups.policies.read' BACKUPS_POLICIES_WRITE = 'backups.policies.write' ARCHIVES_READ = 'archives.read' @@ -122,6 +124,8 @@ module ProjectKeyScopes OAUTH2_READ = 'oauth2.read' OAUTH2_WRITE = 'oauth2.write' OAUTH2_INTROSPECT = 'oauth2.introspect' + ANALYTICS_READ = 'analytics.read' + ANALYTICS_WRITE = 'analytics.write' end end end diff --git a/lib/appwrite/enums/project_o_auth2_auth0_prompt.rb b/lib/appwrite/enums/project_o_auth2_auth0_prompt.rb new file mode 100644 index 00000000..a41bc573 --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_auth0_prompt.rb @@ -0,0 +1,9 @@ +module Appwrite + module Enums + module ProjectOAuth2Auth0Prompt + NONE = 'none' + LOGIN = 'login' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth2_discord_prompt.rb b/lib/appwrite/enums/project_o_auth2_discord_prompt.rb new file mode 100644 index 00000000..d44b4b42 --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_discord_prompt.rb @@ -0,0 +1,8 @@ +module Appwrite + module Enums + module ProjectOAuth2DiscordPrompt + NONE = 'none' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth2_git_hub_prompt.rb b/lib/appwrite/enums/project_o_auth2_git_hub_prompt.rb new file mode 100644 index 00000000..d7cac0eb --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_git_hub_prompt.rb @@ -0,0 +1,7 @@ +module Appwrite + module Enums + module ProjectOAuth2GitHubPrompt + SELECT_ACCOUNT = 'select_account' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth2_kakao_prompt.rb b/lib/appwrite/enums/project_o_auth2_kakao_prompt.rb new file mode 100644 index 00000000..47e7fe96 --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_kakao_prompt.rb @@ -0,0 +1,10 @@ +module Appwrite + module Enums + module ProjectOAuth2KakaoPrompt + NONE = 'none' + LOGIN = 'login' + CREATE = 'create' + SELECT_ACCOUNT = 'select_account' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth2_microsoft_prompt.rb b/lib/appwrite/enums/project_o_auth2_microsoft_prompt.rb new file mode 100644 index 00000000..7eee1d0a --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_microsoft_prompt.rb @@ -0,0 +1,10 @@ +module Appwrite + module Enums + module ProjectOAuth2MicrosoftPrompt + NONE = 'none' + LOGIN = 'login' + CONSENT = 'consent' + SELECT_ACCOUNT = 'select_account' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth2_okta_prompt.rb b/lib/appwrite/enums/project_o_auth2_okta_prompt.rb new file mode 100644 index 00000000..c2ddeaf4 --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_okta_prompt.rb @@ -0,0 +1,9 @@ +module Appwrite + module Enums + module ProjectOAuth2OktaPrompt + NONE = 'none' + LOGIN = 'login' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth2_salesforce_prompt.rb b/lib/appwrite/enums/project_o_auth2_salesforce_prompt.rb new file mode 100644 index 00000000..90c1d432 --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_salesforce_prompt.rb @@ -0,0 +1,8 @@ +module Appwrite + module Enums + module ProjectOAuth2SalesforcePrompt + LOGIN = 'login' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth2_zoho_prompt.rb b/lib/appwrite/enums/project_o_auth2_zoho_prompt.rb new file mode 100644 index 00000000..5b29253a --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_zoho_prompt.rb @@ -0,0 +1,7 @@ +module Appwrite + module Enums + module ProjectOAuth2ZohoPrompt + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth_provider_id.rb b/lib/appwrite/enums/project_o_auth_provider_id.rb index f6b4c97c..946de02f 100644 --- a/lib/appwrite/enums/project_o_auth_provider_id.rb +++ b/lib/appwrite/enums/project_o_auth_provider_id.rb @@ -23,6 +23,7 @@ module ProjectOAuthProviderId GITLAB = 'gitlab' GOOGLE = 'google' HUGGINGFACE = 'huggingface' + KAKAO = 'kakao' KEYCLOAK = 'keycloak' KICK = 'kick' LINKEDIN = 'linkedin' @@ -38,9 +39,11 @@ module ProjectOAuthProviderId SLACK = 'slack' SPOTIFY = 'spotify' STRIPE = 'stripe' + TIKTOK = 'tiktok' TRADESHIFT = 'tradeshift' TRADESHIFTBOX = 'tradeshiftBox' TWITCH = 'twitch' + WEBFLOW = 'webflow' WORDPRESS = 'wordpress' X = 'x' YAHOO = 'yahoo' diff --git a/lib/appwrite/enums/project_policy_id.rb b/lib/appwrite/enums/project_policy_id.rb index ecc9f453..34b8bbe1 100644 --- a/lib/appwrite/enums/project_policy_id.rb +++ b/lib/appwrite/enums/project_policy_id.rb @@ -5,6 +5,8 @@ module ProjectPolicyId PASSWORD_HISTORY = 'password-history' PASSWORD_STRENGTH = 'password-strength' PASSWORD_PERSONAL_DATA = 'password-personal-data' + PASSWORD_PWNED = 'password-pwned' + PASSWORD_ROTATION = 'password-rotation' SESSION_ALERT = 'session-alert' SESSION_DURATION = 'session-duration' SESSION_INVALIDATION = 'session-invalidation' diff --git a/lib/appwrite/enums/proxy_rule_deployment_resource_type.rb b/lib/appwrite/enums/proxy_rule_deployment_resource_type.rb index 89a76ba5..aac33df9 100644 --- a/lib/appwrite/enums/proxy_rule_deployment_resource_type.rb +++ b/lib/appwrite/enums/proxy_rule_deployment_resource_type.rb @@ -3,6 +3,7 @@ module Enums module ProxyRuleDeploymentResourceType FUNCTION = 'function' SITE = 'site' + DEDICATEDDATABASE = 'dedicatedDatabase' end end end diff --git a/lib/appwrite/enums/runtime.rb b/lib/appwrite/enums/runtime.rb index ed615ec7..e151066d 100644 --- a/lib/appwrite/enums/runtime.rb +++ b/lib/appwrite/enums/runtime.rb @@ -52,6 +52,7 @@ module Runtime DART_3_10 = 'dart-3.10' DART_3_11 = 'dart-3.11' DART_3_12 = 'dart-3.12' + DART_3_13 = 'dart-3.13' DOTNET_6_0 = 'dotnet-6.0' DOTNET_7_0 = 'dotnet-7.0' DOTNET_8_0 = 'dotnet-8.0' @@ -94,6 +95,7 @@ module Runtime FLUTTER_3_38 = 'flutter-3.38' FLUTTER_3_41 = 'flutter-3.41' FLUTTER_3_44 = 'flutter-3.44' + FLUTTER_3_47 = 'flutter-3.47' end end end diff --git a/lib/appwrite/enums/tables_db_index_type.rb b/lib/appwrite/enums/tables_db_index_type.rb index 6be77a52..81f346ac 100644 --- a/lib/appwrite/enums/tables_db_index_type.rb +++ b/lib/appwrite/enums/tables_db_index_type.rb @@ -5,6 +5,7 @@ module TablesDBIndexType FULLTEXT = 'fulltext' UNIQUE = 'unique' SPATIAL = 'spatial' + TRIGRAM = 'trigram' end end end diff --git a/lib/appwrite/enums/waf_rule_action.rb b/lib/appwrite/enums/waf_rule_action.rb new file mode 100644 index 00000000..3fa1389e --- /dev/null +++ b/lib/appwrite/enums/waf_rule_action.rb @@ -0,0 +1,11 @@ +module Appwrite + module Enums + module WafRuleAction + BYPASS = 'bypass' + DENY = 'deny' + CHALLENGE = 'challenge' + RATELIMIT = 'rateLimit' + REDIRECT = 'redirect' + end + end +end diff --git a/lib/appwrite/models/account.rb b/lib/appwrite/models/account.rb new file mode 100644 index 00000000..64bcf5f5 --- /dev/null +++ b/lib/appwrite/models/account.rb @@ -0,0 +1,143 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class Account + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :registration + attr_reader :status + attr_reader :labels + attr_reader :password_update + attr_reader :email + attr_reader :phone + attr_reader :email_verification + attr_reader :email_canonical + attr_reader :email_is_free + attr_reader :email_is_disposable + attr_reader :email_is_corporate + attr_reader :email_is_canonical + attr_reader :password_pwned + attr_reader :phone_verification + attr_reader :mfa + attr_reader :prefs + attr_reader :targets + attr_reader :accessed_at + attr_reader :impersonator + attr_reader :impersonator_user_id + + def initialize( + id:, + created_at:, + updated_at:, + name:, + registration:, + status:, + labels:, + password_update:, + email:, + phone:, + email_verification:, + email_canonical:, + email_is_free:, + email_is_disposable:, + email_is_corporate:, + email_is_canonical:, + password_pwned:, + phone_verification:, + mfa:, + prefs:, + targets:, + accessed_at:, + impersonator:, + impersonator_user_id: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @registration = registration + @status = status + @labels = labels + @password_update = password_update + @email = email + @phone = phone + @email_verification = email_verification + @email_canonical = email_canonical + @email_is_free = email_is_free + @email_is_disposable = email_is_disposable + @email_is_corporate = email_is_corporate + @email_is_canonical = email_is_canonical + @password_pwned = password_pwned + @phone_verification = phone_verification + @mfa = mfa + @prefs = prefs + @targets = targets + @accessed_at = accessed_at + @impersonator = impersonator + @impersonator_user_id = impersonator_user_id + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "registration" => "", "status" => true, "labels" => [], "passwordUpdate" => "", "email" => "", "phone" => "", "emailVerification" => false, "phoneVerification" => false, "mfa" => false, "targets" => [], "accessedAt" => "" }.merge(map) + Account.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + registration: map["registration"], + status: map["status"], + labels: map["labels"], + password_update: map["passwordUpdate"], + email: map["email"], + phone: map["phone"], + email_verification: map["emailVerification"], + email_canonical: map["emailCanonical"], + email_is_free: map["emailIsFree"], + email_is_disposable: map["emailIsDisposable"], + email_is_corporate: map["emailIsCorporate"], + email_is_canonical: map["emailIsCanonical"], + password_pwned: map["passwordPwned"], + phone_verification: map["phoneVerification"], + mfa: map["mfa"], + prefs: Preferences.from(map: map["prefs"]), + targets: map["targets"].map { |it| Target.from(map: it) }, + accessed_at: map["accessedAt"], + impersonator: map["impersonator"], + impersonator_user_id: map["impersonatorUserId"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "registration": @registration, + "status": @status, + "labels": @labels, + "passwordUpdate": @password_update, + "email": @email, + "phone": @phone, + "emailVerification": @email_verification, + "emailCanonical": @email_canonical, + "emailIsFree": @email_is_free, + "emailIsDisposable": @email_is_disposable, + "emailIsCorporate": @email_is_corporate, + "emailIsCanonical": @email_is_canonical, + "passwordPwned": @password_pwned, + "phoneVerification": @phone_verification, + "mfa": @mfa, + "prefs": @prefs.to_map, + "targets": @targets.map { |it| it.to_map }, + "accessedAt": @accessed_at, + "impersonator": @impersonator, + "impersonatorUserId": @impersonator_user_id + } + end + end + end +end diff --git a/lib/appwrite/models/billing_plan.rb b/lib/appwrite/models/billing_plan.rb index cac6349d..2a5b6644 100644 --- a/lib/appwrite/models/billing_plan.rb +++ b/lib/appwrite/models/billing_plan.rb @@ -16,6 +16,7 @@ class BillingPlan attr_reader :members attr_reader :webhooks attr_reader :waf_rules + attr_reader :environments attr_reader :projects attr_reader :platforms attr_reader :users @@ -50,6 +51,7 @@ class BillingPlan attr_reader :email_branding attr_reader :requires_payment_method attr_reader :requires_billing_address + attr_reader :eligible_countries attr_reader :is_available attr_reader :self_service attr_reader :premium_support @@ -91,6 +93,7 @@ def initialize( members:, webhooks:, waf_rules:, + environments:, projects:, platforms:, users:, @@ -125,6 +128,7 @@ def initialize( email_branding:, requires_payment_method:, requires_billing_address:, + eligible_countries:, is_available:, self_service:, premium_support:, @@ -165,6 +169,7 @@ def initialize( @members = members @webhooks = webhooks @waf_rules = waf_rules + @environments = environments @projects = projects @platforms = platforms @users = users @@ -199,6 +204,7 @@ def initialize( @email_branding = email_branding @requires_payment_method = requires_payment_method @requires_billing_address = requires_billing_address + @eligible_countries = eligible_countries @is_available = is_available @self_service = self_service @premium_support = premium_support @@ -242,6 +248,7 @@ def self.from(map:) members: map["members"], webhooks: map["webhooks"], waf_rules: map["wafRules"], + environments: map["environments"], projects: map["projects"], platforms: map["platforms"], users: map["users"], @@ -276,6 +283,7 @@ def self.from(map:) email_branding: map["emailBranding"], requires_payment_method: map["requiresPaymentMethod"], requires_billing_address: map["requiresBillingAddress"], + eligible_countries: map["eligibleCountries"], is_available: map["isAvailable"], self_service: map["selfService"], premium_support: map["premiumSupport"], @@ -320,6 +328,7 @@ def to_map "members": @members, "webhooks": @webhooks, "wafRules": @waf_rules, + "environments": @environments, "projects": @projects, "platforms": @platforms, "users": @users, @@ -354,6 +363,7 @@ def to_map "emailBranding": @email_branding, "requiresPaymentMethod": @requires_payment_method, "requiresBillingAddress": @requires_billing_address, + "eligibleCountries": @eligible_countries, "isAvailable": @is_available, "selfService": @self_service, "premiumSupport": @premium_support, @@ -388,6 +398,8 @@ def to_map def validate_group(group) valid_group = [ Appwrite::Enums::BillingPlanGroup::STARTER, + Appwrite::Enums::BillingPlanGroup::FREE, + Appwrite::Enums::BillingPlanGroup::START, Appwrite::Enums::BillingPlanGroup::PRO, Appwrite::Enums::BillingPlanGroup::SCALE, ] diff --git a/lib/appwrite/models/dedicated_database.rb b/lib/appwrite/models/dedicated_database.rb index fd4b0b04..ca683b57 100644 --- a/lib/appwrite/models/dedicated_database.rb +++ b/lib/appwrite/models/dedicated_database.rb @@ -29,6 +29,9 @@ class DedicatedDatabase attr_reader :cpu attr_reader :memory attr_reader :storage + attr_reader :storage_status + attr_reader :storage_target_gb + attr_reader :storage_resize_started_at attr_reader :storage_class attr_reader :storage_max_gb attr_reader :node_pool @@ -80,6 +83,9 @@ def initialize( cpu:, memory:, storage:, + storage_status:, + storage_target_gb:, + storage_resize_started_at:, storage_class:, storage_max_gb:, node_pool:, @@ -130,6 +136,9 @@ def initialize( @cpu = cpu @memory = memory @storage = storage + @storage_status = storage_status + @storage_target_gb = storage_target_gb + @storage_resize_started_at = storage_resize_started_at @storage_class = storage_class @storage_max_gb = storage_max_gb @node_pool = node_pool @@ -183,6 +192,9 @@ def self.from(map:) cpu: map["cpu"], memory: map["memory"], storage: map["storage"], + storage_status: map["storageStatus"], + storage_target_gb: map["storageTargetGb"], + storage_resize_started_at: map["storageResizeStartedAt"], storage_class: map["storageClass"], storage_max_gb: map["storageMaxGb"], node_pool: map["nodePool"], @@ -237,6 +249,9 @@ def to_map "cpu": @cpu, "memory": @memory, "storage": @storage, + "storageStatus": @storage_status, + "storageTargetGb": @storage_target_gb, + "storageResizeStartedAt": @storage_resize_started_at, "storageClass": @storage_class, "storageMaxGb": @storage_max_gb, "nodePool": @node_pool, diff --git a/lib/appwrite/models/dedicated_database_specification.rb b/lib/appwrite/models/dedicated_database_specification.rb index 2448c2e1..b5f26a33 100644 --- a/lib/appwrite/models/dedicated_database_specification.rb +++ b/lib/appwrite/models/dedicated_database_specification.rb @@ -6,6 +6,10 @@ class DedicatedDatabaseSpecification attr_reader :slug attr_reader :name attr_reader :price + attr_reader :storage_overage_rate + attr_reader :bandwidth_overage_rate + attr_reader :replica_rate + attr_reader :pitr_rate attr_reader :cpu attr_reader :memory attr_reader :max_connections @@ -17,6 +21,10 @@ def initialize( slug:, name:, price:, + storage_overage_rate:, + bandwidth_overage_rate:, + replica_rate:, + pitr_rate:, cpu:, memory:, max_connections:, @@ -27,6 +35,10 @@ def initialize( @slug = slug @name = name @price = price + @storage_overage_rate = storage_overage_rate + @bandwidth_overage_rate = bandwidth_overage_rate + @replica_rate = replica_rate + @pitr_rate = pitr_rate @cpu = cpu @memory = memory @max_connections = max_connections @@ -40,6 +52,10 @@ def self.from(map:) slug: map["slug"], name: map["name"], price: map["price"], + storage_overage_rate: map["storageOverageRate"], + bandwidth_overage_rate: map["bandwidthOverageRate"], + replica_rate: map["replicaRate"], + pitr_rate: map["pitrRate"], cpu: map["cpu"], memory: map["memory"], max_connections: map["maxConnections"], @@ -54,6 +70,10 @@ def to_map "slug": @slug, "name": @name, "price": @price, + "storageOverageRate": @storage_overage_rate, + "bandwidthOverageRate": @bandwidth_overage_rate, + "replicaRate": @replica_rate, + "pitrRate": @pitr_rate, "cpu": @cpu, "memory": @memory, "maxConnections": @max_connections, diff --git a/lib/appwrite/models/dns_record.rb b/lib/appwrite/models/dns_record.rb new file mode 100644 index 00000000..7dce4df7 --- /dev/null +++ b/lib/appwrite/models/dns_record.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class DnsRecord + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :type + attr_reader :name + attr_reader :value + attr_reader :ttl + attr_reader :priority + attr_reader :lock + attr_reader :weight + attr_reader :port + attr_reader :comment + + def initialize( + id:, + created_at:, + updated_at:, + type:, + name:, + value:, + ttl:, + priority:, + lock:, + weight:, + port:, + comment: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @type = type + @name = name + @value = value + @ttl = ttl + @priority = priority + @lock = lock + @weight = weight + @port = port + @comment = comment + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "type" => "", "name" => "", "value" => "", "ttl" => 3600, "priority" => 0, "lock" => false, "weight" => 0, "port" => 0, "comment" => "" }.merge(map) + DnsRecord.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + type: map["type"], + name: map["name"], + value: map["value"], + ttl: map["ttl"], + priority: map["priority"], + lock: map["lock"], + weight: map["weight"], + port: map["port"], + comment: map["comment"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "type": @type, + "name": @name, + "value": @value, + "ttl": @ttl, + "priority": @priority, + "lock": @lock, + "weight": @weight, + "port": @port, + "comment": @comment + } + end + end + end +end diff --git a/lib/appwrite/models/dns_records_list.rb b/lib/appwrite/models/dns_records_list.rb new file mode 100644 index 00000000..f3f73e31 --- /dev/null +++ b/lib/appwrite/models/dns_records_list.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class DnsRecordsList + attr_reader :total + attr_reader :dns_records + + def initialize( + total:, + dns_records: + ) + @total = total + @dns_records = dns_records + end + + def self.from(map:) + map = { "total" => 0, "dnsRecords" => [] }.merge(map) + DnsRecordsList.new( + total: map["total"], + dns_records: map["dnsRecords"].map { |it| DnsRecord.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "dnsRecords": @dns_records.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/domain.rb b/lib/appwrite/models/domain.rb new file mode 100644 index 00000000..dda43a3a --- /dev/null +++ b/lib/appwrite/models/domain.rb @@ -0,0 +1,109 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class Domain + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :domain + attr_reader :registrar + attr_reader :nameservers + attr_reader :expire + attr_reader :renewal + attr_reader :auto_renewal + attr_reader :renewal_price + attr_reader :transfer_status + attr_reader :team_id + attr_reader :dns_records + + def initialize( + id:, + created_at:, + updated_at:, + domain:, + registrar:, + nameservers:, + expire:, + renewal:, + auto_renewal:, + renewal_price:, + transfer_status:, + team_id:, + dns_records: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @domain = domain + @registrar = registrar + @nameservers = nameservers + @expire = expire + @renewal = renewal + @auto_renewal = auto_renewal + @renewal_price = renewal_price + @transfer_status = transfer_status.nil? ? transfer_status : validate_transfer_status(transfer_status) + @team_id = team_id + @dns_records = dns_records + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "domain" => "", "registrar" => "", "nameservers" => "", "expire" => "", "renewal" => "", "autoRenewal" => false, "renewalPrice" => 0, "teamId" => "", "dnsRecords" => [] }.merge(map) + Domain.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + domain: map["domain"], + registrar: map["registrar"], + nameservers: map["nameservers"], + expire: map["expire"], + renewal: map["renewal"], + auto_renewal: map["autoRenewal"], + renewal_price: map["renewalPrice"], + transfer_status: map["transferStatus"], + team_id: map["teamId"], + dns_records: map["dnsRecords"].map { |it| DnsRecord.from(map: it) } + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "domain": @domain, + "registrar": @registrar, + "nameservers": @nameservers, + "expire": @expire, + "renewal": @renewal, + "autoRenewal": @auto_renewal, + "renewalPrice": @renewal_price, + "transferStatus": @transfer_status, + "teamId": @team_id, + "dnsRecords": @dns_records.map { |it| it.to_map } + } + end + + private + + def validate_transfer_status(transfer_status) + valid_transfer_status = [ + Appwrite::Enums::DomainTransferStatusEnum::TRANSFERRABLE, + Appwrite::Enums::DomainTransferStatusEnum::NOT_TRANSFERRABLE, + Appwrite::Enums::DomainTransferStatusEnum::PENDING_OWNER, + Appwrite::Enums::DomainTransferStatusEnum::PENDING_ADMIN, + Appwrite::Enums::DomainTransferStatusEnum::PENDING_REGISTRY, + Appwrite::Enums::DomainTransferStatusEnum::COMPLETED, + Appwrite::Enums::DomainTransferStatusEnum::CANCELLED, + Appwrite::Enums::DomainTransferStatusEnum::SERVICE_UNAVAILABLE, + ] + + unless valid_transfer_status.include?(transfer_status) + raise ArgumentError, "Invalid " + transfer_status + ". Must be one of: " + valid_transfer_status.join(', ') + end + + transfer_status + end + end + end +end diff --git a/lib/appwrite/models/domain_price.rb b/lib/appwrite/models/domain_price.rb new file mode 100644 index 00000000..c67f7263 --- /dev/null +++ b/lib/appwrite/models/domain_price.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class DomainPrice + attr_reader :domain + attr_reader :tld + attr_reader :available + attr_reader :price + attr_reader :period_years + attr_reader :premium + attr_reader :renewal_price + attr_reader :renewal_period_years + + def initialize( + domain:, + tld:, + available:, + price:, + period_years:, + premium:, + renewal_price:, + renewal_period_years: + ) + @domain = domain + @tld = tld + @available = available + @price = price + @period_years = period_years + @premium = premium + @renewal_price = renewal_price + @renewal_period_years = renewal_period_years + end + + def self.from(map:) + map = { "domain" => "", "tld" => "", "available" => false, "periodYears" => 1, "premium" => false, "renewalPeriodYears" => 1 }.merge(map) + DomainPrice.new( + domain: map["domain"], + tld: map["tld"], + available: map["available"], + price: map["price"], + period_years: map["periodYears"], + premium: map["premium"], + renewal_price: map["renewalPrice"], + renewal_period_years: map["renewalPeriodYears"] + ) + end + + def to_map + { + "domain": @domain, + "tld": @tld, + "available": @available, + "price": @price, + "periodYears": @period_years, + "premium": @premium, + "renewalPrice": @renewal_price, + "renewalPeriodYears": @renewal_period_years + } + end + end + end +end diff --git a/lib/appwrite/models/domain_prices_list.rb b/lib/appwrite/models/domain_prices_list.rb new file mode 100644 index 00000000..1291f2eb --- /dev/null +++ b/lib/appwrite/models/domain_prices_list.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class DomainPricesList + attr_reader :total + attr_reader :prices + + def initialize( + total:, + prices: + ) + @total = total + @prices = prices + end + + def self.from(map:) + map = { "total" => 0, "prices" => [] }.merge(map) + DomainPricesList.new( + total: map["total"], + prices: map["prices"].map { |it| DomainPrice.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "prices": @prices.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/domain_transfer_status.rb b/lib/appwrite/models/domain_transfer_status.rb new file mode 100644 index 00000000..911b13ae --- /dev/null +++ b/lib/appwrite/models/domain_transfer_status.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class DomainTransferStatus + attr_reader :status + attr_reader :reason + attr_reader :timestamp + + def initialize( + status:, + reason:, + timestamp: + ) + @status = validate_status(status) + @reason = reason + @timestamp = timestamp + end + + def self.from(map:) + map = { "status" => "pending_registry", "reason" => "", "timestamp" => "" }.merge(map) + DomainTransferStatus.new( + status: map["status"], + reason: map["reason"], + timestamp: map["timestamp"] + ) + end + + def to_map + { + "status": @status, + "reason": @reason, + "timestamp": @timestamp + } + end + + private + + def validate_status(status) + valid_status = [ + Appwrite::Enums::DomainTransferStatusEnum::TRANSFERRABLE, + Appwrite::Enums::DomainTransferStatusEnum::NOT_TRANSFERRABLE, + Appwrite::Enums::DomainTransferStatusEnum::PENDING_OWNER, + Appwrite::Enums::DomainTransferStatusEnum::PENDING_ADMIN, + Appwrite::Enums::DomainTransferStatusEnum::PENDING_REGISTRY, + Appwrite::Enums::DomainTransferStatusEnum::COMPLETED, + Appwrite::Enums::DomainTransferStatusEnum::CANCELLED, + Appwrite::Enums::DomainTransferStatusEnum::SERVICE_UNAVAILABLE, + ] + + unless valid_status.include?(status) + raise ArgumentError, "Invalid " + status + ". Must be one of: " + valid_status.join(', ') + end + + status + end + end + end +end diff --git a/lib/appwrite/models/domains_list.rb b/lib/appwrite/models/domains_list.rb new file mode 100644 index 00000000..873eed16 --- /dev/null +++ b/lib/appwrite/models/domains_list.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class DomainsList + attr_reader :total + attr_reader :domains + + def initialize( + total:, + domains: + ) + @total = total + @domains = domains + end + + def self.from(map:) + map = { "total" => 0, "domains" => [] }.merge(map) + DomainsList.new( + total: map["total"], + domains: map["domains"].map { |it| Domain.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "domains": @domains.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/identity.rb b/lib/appwrite/models/identity.rb index bd6e58cf..abf586a2 100644 --- a/lib/appwrite/models/identity.rb +++ b/lib/appwrite/models/identity.rb @@ -13,6 +13,7 @@ class Identity attr_reader :provider_access_token attr_reader :provider_access_token_expiry attr_reader :provider_refresh_token + attr_reader :provider_id_token def initialize( id:, @@ -24,7 +25,8 @@ def initialize( provider_email:, provider_access_token:, provider_access_token_expiry:, - provider_refresh_token: + provider_refresh_token:, + provider_id_token: ) @id = id @created_at = created_at @@ -36,6 +38,7 @@ def initialize( @provider_access_token = provider_access_token @provider_access_token_expiry = provider_access_token_expiry @provider_refresh_token = provider_refresh_token + @provider_id_token = provider_id_token end def self.from(map:) @@ -49,7 +52,8 @@ def self.from(map:) provider_email: map["providerEmail"], provider_access_token: map["providerAccessToken"], provider_access_token_expiry: map["providerAccessTokenExpiry"], - provider_refresh_token: map["providerRefreshToken"] + provider_refresh_token: map["providerRefreshToken"], + provider_id_token: map["providerIdToken"] ) end @@ -64,7 +68,8 @@ def to_map "providerEmail": @provider_email, "providerAccessToken": @provider_access_token, "providerAccessTokenExpiry": @provider_access_token_expiry, - "providerRefreshToken": @provider_refresh_token + "providerRefreshToken": @provider_refresh_token, + "providerIdToken": @provider_id_token } end end diff --git a/lib/appwrite/models/o_auth2_apple.rb b/lib/appwrite/models/o_auth2_apple.rb index bc7d9cba..f5949d06 100644 --- a/lib/appwrite/models/o_auth2_apple.rb +++ b/lib/appwrite/models/o_auth2_apple.rb @@ -9,6 +9,8 @@ class OAuth2Apple attr_reader :key_id attr_reader :team_id attr_reader :p8_file + attr_reader :native_enabled + attr_reader :native_client_ids def initialize( id:, @@ -16,7 +18,9 @@ def initialize( service_id:, key_id:, team_id:, - p8_file: + p8_file:, + native_enabled:, + native_client_ids: ) @id = id @enabled = enabled @@ -24,6 +28,8 @@ def initialize( @key_id = key_id @team_id = team_id @p8_file = p8_file + @native_enabled = native_enabled + @native_client_ids = native_client_ids end def self.from(map:) @@ -33,7 +39,9 @@ def self.from(map:) service_id: map["serviceId"], key_id: map["keyId"], team_id: map["teamId"], - p8_file: map["p8File"] + p8_file: map["p8File"], + native_enabled: map["nativeEnabled"], + native_client_ids: map["nativeClientIds"] ) end @@ -44,7 +52,9 @@ def to_map "serviceId": @service_id, "keyId": @key_id, "teamId": @team_id, - "p8File": @p8_file + "p8File": @p8_file, + "nativeEnabled": @native_enabled, + "nativeClientIds": @native_client_ids } end end diff --git a/lib/appwrite/models/o_auth2_auth0.rb b/lib/appwrite/models/o_auth2_auth0.rb index aa261435..e9cf3cb0 100644 --- a/lib/appwrite/models/o_auth2_auth0.rb +++ b/lib/appwrite/models/o_auth2_auth0.rb @@ -7,6 +7,7 @@ class OAuth2Auth0 attr_reader :enabled attr_reader :client_id attr_reader :client_secret + attr_reader :prompt attr_reader :endpoint def initialize( @@ -14,12 +15,14 @@ def initialize( enabled:, client_id:, client_secret:, + prompt:, endpoint: ) @id = id @enabled = enabled @client_id = client_id @client_secret = client_secret + @prompt = prompt.nil? ? prompt : validate_prompt(prompt) @endpoint = endpoint end @@ -29,6 +32,7 @@ def self.from(map:) enabled: map["enabled"], client_id: map["clientId"], client_secret: map["clientSecret"], + prompt: map["prompt"], endpoint: map["endpoint"] ) end @@ -39,9 +43,28 @@ def to_map "enabled": @enabled, "clientId": @client_id, "clientSecret": @client_secret, + "prompt": @prompt, "endpoint": @endpoint } end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2Auth0Prompt::NONE, + Appwrite::Enums::OAuth2Auth0Prompt::LOGIN, + Appwrite::Enums::OAuth2Auth0Prompt::CONSENT, + ] + + (prompt || []).each do |value| + unless valid_prompt.include?(value) + raise ArgumentError, "Invalid " + value.to_s + ". Must be one of: " + valid_prompt.join(', ') + end + end + + prompt + end end end end diff --git a/lib/appwrite/models/o_auth2_discord.rb b/lib/appwrite/models/o_auth2_discord.rb index b24b44c8..5d7db0cb 100644 --- a/lib/appwrite/models/o_auth2_discord.rb +++ b/lib/appwrite/models/o_auth2_discord.rb @@ -7,17 +7,20 @@ class OAuth2Discord attr_reader :enabled attr_reader :client_id attr_reader :client_secret + attr_reader :prompt def initialize( id:, enabled:, client_id:, - client_secret: + client_secret:, + prompt: ) @id = id @enabled = enabled @client_id = client_id @client_secret = client_secret + @prompt = prompt.nil? ? prompt : validate_prompt(prompt) end def self.from(map:) @@ -25,7 +28,8 @@ def self.from(map:) id: map["$id"], enabled: map["enabled"], client_id: map["clientId"], - client_secret: map["clientSecret"] + client_secret: map["clientSecret"], + prompt: map["prompt"] ) end @@ -34,9 +38,27 @@ def to_map "$id": @id, "enabled": @enabled, "clientId": @client_id, - "clientSecret": @client_secret + "clientSecret": @client_secret, + "prompt": @prompt } end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2DiscordPrompt::NONE, + Appwrite::Enums::OAuth2DiscordPrompt::CONSENT, + ] + + (prompt || []).each do |value| + unless valid_prompt.include?(value) + raise ArgumentError, "Invalid " + value.to_s + ". Must be one of: " + valid_prompt.join(', ') + end + end + + prompt + end end end end diff --git a/lib/appwrite/models/o_auth2_github.rb b/lib/appwrite/models/o_auth2_github.rb index 9f72146a..d46e1e38 100644 --- a/lib/appwrite/models/o_auth2_github.rb +++ b/lib/appwrite/models/o_auth2_github.rb @@ -7,17 +7,20 @@ class OAuth2Github attr_reader :enabled attr_reader :client_id attr_reader :client_secret + attr_reader :prompt def initialize( id:, enabled:, client_id:, - client_secret: + client_secret:, + prompt: ) @id = id @enabled = enabled @client_id = client_id @client_secret = client_secret + @prompt = prompt.nil? ? prompt : validate_prompt(prompt) end def self.from(map:) @@ -25,7 +28,8 @@ def self.from(map:) id: map["$id"], enabled: map["enabled"], client_id: map["clientId"], - client_secret: map["clientSecret"] + client_secret: map["clientSecret"], + prompt: map["prompt"] ) end @@ -34,9 +38,26 @@ def to_map "$id": @id, "enabled": @enabled, "clientId": @client_id, - "clientSecret": @client_secret + "clientSecret": @client_secret, + "prompt": @prompt } end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2GithubPrompt::SELECT_ACCOUNT, + ] + + (prompt || []).each do |value| + unless valid_prompt.include?(value) + raise ArgumentError, "Invalid " + value.to_s + ". Must be one of: " + valid_prompt.join(', ') + end + end + + prompt + end end end end diff --git a/lib/appwrite/models/o_auth2_google.rb b/lib/appwrite/models/o_auth2_google.rb index e220ee69..b646c30d 100644 --- a/lib/appwrite/models/o_auth2_google.rb +++ b/lib/appwrite/models/o_auth2_google.rb @@ -8,19 +8,25 @@ class OAuth2Google attr_reader :client_id attr_reader :client_secret attr_reader :prompt + attr_reader :native_enabled + attr_reader :native_client_ids def initialize( id:, enabled:, client_id:, client_secret:, - prompt: + prompt:, + native_enabled:, + native_client_ids: ) @id = id @enabled = enabled @client_id = client_id @client_secret = client_secret @prompt = validate_prompt(prompt) + @native_enabled = native_enabled + @native_client_ids = native_client_ids end def self.from(map:) @@ -29,7 +35,9 @@ def self.from(map:) enabled: map["enabled"], client_id: map["clientId"], client_secret: map["clientSecret"], - prompt: map["prompt"] + prompt: map["prompt"], + native_enabled: map["nativeEnabled"], + native_client_ids: map["nativeClientIds"] ) end @@ -39,7 +47,9 @@ def to_map "enabled": @enabled, "clientId": @client_id, "clientSecret": @client_secret, - "prompt": @prompt + "prompt": @prompt, + "nativeEnabled": @native_enabled, + "nativeClientIds": @native_client_ids } end @@ -52,8 +62,10 @@ def validate_prompt(prompt) Appwrite::Enums::OAuth2GooglePrompt::SELECT_ACCOUNT, ] - unless valid_prompt.include?(prompt) - raise ArgumentError, "Invalid " + prompt + ". Must be one of: " + valid_prompt.join(', ') + (prompt || []).each do |value| + unless valid_prompt.include?(value) + raise ArgumentError, "Invalid " + value.to_s + ". Must be one of: " + valid_prompt.join(', ') + end end prompt diff --git a/lib/appwrite/models/o_auth2_kakao.rb b/lib/appwrite/models/o_auth2_kakao.rb new file mode 100644 index 00000000..172ff96c --- /dev/null +++ b/lib/appwrite/models/o_auth2_kakao.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class OAuth2Kakao + attr_reader :id + attr_reader :enabled + attr_reader :client_id + attr_reader :client_secret + attr_reader :prompt + + def initialize( + id:, + enabled:, + client_id:, + client_secret:, + prompt: + ) + @id = id + @enabled = enabled + @client_id = client_id + @client_secret = client_secret + @prompt = validate_prompt(prompt) + end + + def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [] }.merge(map) + OAuth2Kakao.new( + id: map["$id"], + enabled: map["enabled"], + client_id: map["clientId"], + client_secret: map["clientSecret"], + prompt: map["prompt"] + ) + end + + def to_map + { + "$id": @id, + "enabled": @enabled, + "clientId": @client_id, + "clientSecret": @client_secret, + "prompt": @prompt + } + end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2KakaoPrompt::NONE, + Appwrite::Enums::OAuth2KakaoPrompt::LOGIN, + Appwrite::Enums::OAuth2KakaoPrompt::CREATE, + Appwrite::Enums::OAuth2KakaoPrompt::SELECT_ACCOUNT, + ] + + (prompt || []).each do |value| + unless valid_prompt.include?(value) + raise ArgumentError, "Invalid " + value.to_s + ". Must be one of: " + valid_prompt.join(', ') + end + end + + prompt + end + end + end +end diff --git a/lib/appwrite/models/o_auth2_microsoft.rb b/lib/appwrite/models/o_auth2_microsoft.rb index 0173d394..29c2cb1e 100644 --- a/lib/appwrite/models/o_auth2_microsoft.rb +++ b/lib/appwrite/models/o_auth2_microsoft.rb @@ -7,6 +7,7 @@ class OAuth2Microsoft attr_reader :enabled attr_reader :application_id attr_reader :application_secret + attr_reader :prompt attr_reader :tenant def initialize( @@ -14,12 +15,14 @@ def initialize( enabled:, application_id:, application_secret:, + prompt:, tenant: ) @id = id @enabled = enabled @application_id = application_id @application_secret = application_secret + @prompt = prompt.nil? ? prompt : validate_prompt(prompt) @tenant = tenant end @@ -29,6 +32,7 @@ def self.from(map:) enabled: map["enabled"], application_id: map["applicationId"], application_secret: map["applicationSecret"], + prompt: map["prompt"], tenant: map["tenant"] ) end @@ -39,9 +43,29 @@ def to_map "enabled": @enabled, "applicationId": @application_id, "applicationSecret": @application_secret, + "prompt": @prompt, "tenant": @tenant } end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2MicrosoftPrompt::NONE, + Appwrite::Enums::OAuth2MicrosoftPrompt::LOGIN, + Appwrite::Enums::OAuth2MicrosoftPrompt::CONSENT, + Appwrite::Enums::OAuth2MicrosoftPrompt::SELECT_ACCOUNT, + ] + + (prompt || []).each do |value| + unless valid_prompt.include?(value) + raise ArgumentError, "Invalid " + value.to_s + ". Must be one of: " + valid_prompt.join(', ') + end + end + + prompt + end end end end diff --git a/lib/appwrite/models/o_auth2_oidc.rb b/lib/appwrite/models/o_auth2_oidc.rb index a4ea66fe..a034231b 100644 --- a/lib/appwrite/models/o_auth2_oidc.rb +++ b/lib/appwrite/models/o_auth2_oidc.rb @@ -78,8 +78,10 @@ def validate_prompt(prompt) Appwrite::Enums::OAuth2OidcPrompt::SELECT_ACCOUNT, ] - unless valid_prompt.include?(prompt) - raise ArgumentError, "Invalid " + prompt + ". Must be one of: " + valid_prompt.join(', ') + (prompt || []).each do |value| + unless valid_prompt.include?(value) + raise ArgumentError, "Invalid " + value.to_s + ". Must be one of: " + valid_prompt.join(', ') + end end prompt diff --git a/lib/appwrite/models/o_auth2_okta.rb b/lib/appwrite/models/o_auth2_okta.rb index 61ef16ec..11d5746f 100644 --- a/lib/appwrite/models/o_auth2_okta.rb +++ b/lib/appwrite/models/o_auth2_okta.rb @@ -7,6 +7,7 @@ class OAuth2Okta attr_reader :enabled attr_reader :client_id attr_reader :client_secret + attr_reader :prompt attr_reader :domain attr_reader :authorization_server_id @@ -15,6 +16,7 @@ def initialize( enabled:, client_id:, client_secret:, + prompt:, domain:, authorization_server_id: ) @@ -22,6 +24,7 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret + @prompt = prompt.nil? ? prompt : validate_prompt(prompt) @domain = domain @authorization_server_id = authorization_server_id end @@ -32,6 +35,7 @@ def self.from(map:) enabled: map["enabled"], client_id: map["clientId"], client_secret: map["clientSecret"], + prompt: map["prompt"], domain: map["domain"], authorization_server_id: map["authorizationServerId"] ) @@ -43,10 +47,29 @@ def to_map "enabled": @enabled, "clientId": @client_id, "clientSecret": @client_secret, + "prompt": @prompt, "domain": @domain, "authorizationServerId": @authorization_server_id } end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2OktaPrompt::NONE, + Appwrite::Enums::OAuth2OktaPrompt::LOGIN, + Appwrite::Enums::OAuth2OktaPrompt::CONSENT, + ] + + (prompt || []).each do |value| + unless valid_prompt.include?(value) + raise ArgumentError, "Invalid " + value.to_s + ". Must be one of: " + valid_prompt.join(', ') + end + end + + prompt + end end end end diff --git a/lib/appwrite/models/o_auth2_salesforce.rb b/lib/appwrite/models/o_auth2_salesforce.rb index 22cdf2b6..0cd7bc78 100644 --- a/lib/appwrite/models/o_auth2_salesforce.rb +++ b/lib/appwrite/models/o_auth2_salesforce.rb @@ -7,17 +7,20 @@ class OAuth2Salesforce attr_reader :enabled attr_reader :customer_key attr_reader :customer_secret + attr_reader :prompt def initialize( id:, enabled:, customer_key:, - customer_secret: + customer_secret:, + prompt: ) @id = id @enabled = enabled @customer_key = customer_key @customer_secret = customer_secret + @prompt = prompt.nil? ? prompt : validate_prompt(prompt) end def self.from(map:) @@ -25,7 +28,8 @@ def self.from(map:) id: map["$id"], enabled: map["enabled"], customer_key: map["customerKey"], - customer_secret: map["customerSecret"] + customer_secret: map["customerSecret"], + prompt: map["prompt"] ) end @@ -34,9 +38,27 @@ def to_map "$id": @id, "enabled": @enabled, "customerKey": @customer_key, - "customerSecret": @customer_secret + "customerSecret": @customer_secret, + "prompt": @prompt } end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2SalesforcePrompt::LOGIN, + Appwrite::Enums::OAuth2SalesforcePrompt::CONSENT, + ] + + (prompt || []).each do |value| + unless valid_prompt.include?(value) + raise ArgumentError, "Invalid " + value.to_s + ". Must be one of: " + valid_prompt.join(', ') + end + end + + prompt + end end end end diff --git a/lib/appwrite/models/o_auth2_tik_tok.rb b/lib/appwrite/models/o_auth2_tik_tok.rb new file mode 100644 index 00000000..65a4b630 --- /dev/null +++ b/lib/appwrite/models/o_auth2_tik_tok.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class OAuth2TikTok + attr_reader :id + attr_reader :enabled + attr_reader :client_id + attr_reader :client_secret + + def initialize( + id:, + enabled:, + client_id:, + client_secret: + ) + @id = id + @enabled = enabled + @client_id = client_id + @client_secret = client_secret + end + + def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) + OAuth2TikTok.new( + id: map["$id"], + enabled: map["enabled"], + client_id: map["clientId"], + client_secret: map["clientSecret"] + ) + end + + def to_map + { + "$id": @id, + "enabled": @enabled, + "clientId": @client_id, + "clientSecret": @client_secret + } + end + end + end +end diff --git a/lib/appwrite/models/o_auth2_webflow.rb b/lib/appwrite/models/o_auth2_webflow.rb new file mode 100644 index 00000000..a25ce1b4 --- /dev/null +++ b/lib/appwrite/models/o_auth2_webflow.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class OAuth2Webflow + attr_reader :id + attr_reader :enabled + attr_reader :client_id + attr_reader :client_secret + + def initialize( + id:, + enabled:, + client_id:, + client_secret: + ) + @id = id + @enabled = enabled + @client_id = client_id + @client_secret = client_secret + end + + def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) + OAuth2Webflow.new( + id: map["$id"], + enabled: map["enabled"], + client_id: map["clientId"], + client_secret: map["clientSecret"] + ) + end + + def to_map + { + "$id": @id, + "enabled": @enabled, + "clientId": @client_id, + "clientSecret": @client_secret + } + end + end + end +end diff --git a/lib/appwrite/models/o_auth2_zoho.rb b/lib/appwrite/models/o_auth2_zoho.rb index 6b40cab0..792da041 100644 --- a/lib/appwrite/models/o_auth2_zoho.rb +++ b/lib/appwrite/models/o_auth2_zoho.rb @@ -7,17 +7,20 @@ class OAuth2Zoho attr_reader :enabled attr_reader :client_id attr_reader :client_secret + attr_reader :prompt def initialize( id:, enabled:, client_id:, - client_secret: + client_secret:, + prompt: ) @id = id @enabled = enabled @client_id = client_id @client_secret = client_secret + @prompt = prompt.nil? ? prompt : validate_prompt(prompt) end def self.from(map:) @@ -25,7 +28,8 @@ def self.from(map:) id: map["$id"], enabled: map["enabled"], client_id: map["clientId"], - client_secret: map["clientSecret"] + client_secret: map["clientSecret"], + prompt: map["prompt"] ) end @@ -34,9 +38,26 @@ def to_map "$id": @id, "enabled": @enabled, "clientId": @client_id, - "clientSecret": @client_secret + "clientSecret": @client_secret, + "prompt": @prompt } end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2ZohoPrompt::CONSENT, + ] + + (prompt || []).each do |value| + unless valid_prompt.include?(value) + raise ArgumentError, "Invalid " + value.to_s + ". Must be one of: " + valid_prompt.join(', ') + end + end + + prompt + end end end end diff --git a/lib/appwrite/models/oauth2_introspection.rb b/lib/appwrite/models/oauth2_introspection.rb new file mode 100644 index 00000000..ac104dc4 --- /dev/null +++ b/lib/appwrite/models/oauth2_introspection.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class Oauth2Introspection + attr_reader :active + attr_reader :token_use + attr_reader :token_type + attr_reader :scope + attr_reader :client_id + attr_reader :sub + attr_reader :aud + attr_reader :iss + attr_reader :exp + attr_reader :iat + attr_reader :jti + attr_reader :authorization_details + + def initialize( + active:, + token_use:, + token_type:, + scope:, + client_id:, + sub:, + aud:, + iss:, + exp:, + iat:, + jti:, + authorization_details: + ) + @active = active + @token_use = token_use + @token_type = token_type + @scope = scope + @client_id = client_id + @sub = sub + @aud = aud + @iss = iss + @exp = exp + @iat = iat + @jti = jti + @authorization_details = authorization_details + end + + def self.from(map:) + map = { "active" => false }.merge(map) + Oauth2Introspection.new( + active: map["active"], + token_use: map["token_use"], + token_type: map["token_type"], + scope: map["scope"], + client_id: map["client_id"], + sub: map["sub"], + aud: map["aud"], + iss: map["iss"], + exp: map["exp"], + iat: map["iat"], + jti: map["jti"], + authorization_details: map["authorization_details"] + ) + end + + def to_map + { + "active": @active, + "token_use": @token_use, + "token_type": @token_type, + "scope": @scope, + "client_id": @client_id, + "sub": @sub, + "aud": @aud, + "iss": @iss, + "exp": @exp, + "iat": @iat, + "jti": @jti, + "authorization_details": @authorization_details + } + end + end + end +end diff --git a/lib/appwrite/models/platform_android.rb b/lib/appwrite/models/platform_android.rb index 64b05d7d..da5ba79b 100644 --- a/lib/appwrite/models/platform_android.rb +++ b/lib/appwrite/models/platform_android.rb @@ -9,6 +9,7 @@ class PlatformAndroid attr_reader :name attr_reader :type attr_reader :application_id + attr_reader :fingerprints def initialize( id:, @@ -16,7 +17,8 @@ def initialize( updated_at:, name:, type:, - application_id: + application_id:, + fingerprints: ) @id = id @created_at = created_at @@ -24,6 +26,7 @@ def initialize( @name = name @type = validate_type(type) @application_id = application_id + @fingerprints = fingerprints end def self.from(map:) @@ -33,7 +36,8 @@ def self.from(map:) updated_at: map["$updatedAt"], name: map["name"], type: map["type"], - application_id: map["applicationId"] + application_id: map["applicationId"], + fingerprints: map["fingerprints"] ) end @@ -44,7 +48,8 @@ def to_map "$updatedAt": @updated_at, "name": @name, "type": @type, - "applicationId": @application_id + "applicationId": @application_id, + "fingerprints": @fingerprints } end diff --git a/lib/appwrite/models/policy_password_pwned.rb b/lib/appwrite/models/policy_password_pwned.rb new file mode 100644 index 00000000..e2365e96 --- /dev/null +++ b/lib/appwrite/models/policy_password_pwned.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class PolicyPasswordPwned + attr_reader :id + attr_reader :enabled + attr_reader :sessions + attr_reader :users + + def initialize( + id:, + enabled:, + sessions:, + users: + ) + @id = id + @enabled = enabled + @sessions = sessions + @users = users + end + + def self.from(map:) + map = { "$id" => "", "enabled" => true, "sessions" => false, "users" => false }.merge(map) + PolicyPasswordPwned.new( + id: map["$id"], + enabled: map["enabled"], + sessions: map["sessions"], + users: map["users"] + ) + end + + def to_map + { + "$id": @id, + "enabled": @enabled, + "sessions": @sessions, + "users": @users + } + end + end + end +end diff --git a/lib/appwrite/models/policy_password_rotation.rb b/lib/appwrite/models/policy_password_rotation.rb new file mode 100644 index 00000000..c451d766 --- /dev/null +++ b/lib/appwrite/models/policy_password_rotation.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class PolicyPasswordRotation + attr_reader :id + attr_reader :enabled + attr_reader :max_age + + def initialize( + id:, + enabled:, + max_age: + ) + @id = id + @enabled = enabled + @max_age = max_age + end + + def self.from(map:) + map = { "$id" => "", "enabled" => false, "maxAge" => 31536000 }.merge(map) + PolicyPasswordRotation.new( + id: map["$id"], + enabled: map["enabled"], + max_age: map["maxAge"] + ) + end + + def to_map + { + "$id": @id, + "enabled": @enabled, + "maxAge": @max_age + } + end + end + end +end diff --git a/lib/appwrite/models/project.rb b/lib/appwrite/models/project.rb index 3e508814..b03fcbc6 100644 --- a/lib/appwrite/models/project.rb +++ b/lib/appwrite/models/project.rb @@ -31,7 +31,10 @@ class Project attr_reader :blocks attr_reader :console_accessed_at attr_reader :waf_enabled + attr_reader :parent_id attr_reader :billing_limits + attr_reader :first_accessed_at + attr_reader :mcp_accessed_at attr_reader :o_auth2_server_enabled attr_reader :o_auth2_server_authorization_url attr_reader :o_auth2_server_scopes @@ -79,7 +82,10 @@ def initialize( blocks:, console_accessed_at:, waf_enabled:, + parent_id:, billing_limits:, + first_accessed_at:, + mcp_accessed_at:, o_auth2_server_enabled:, o_auth2_server_authorization_url:, o_auth2_server_scopes:, @@ -126,7 +132,10 @@ def initialize( @blocks = blocks @console_accessed_at = console_accessed_at @waf_enabled = waf_enabled + @parent_id = parent_id @billing_limits = billing_limits + @first_accessed_at = first_accessed_at + @mcp_accessed_at = mcp_accessed_at @o_auth2_server_enabled = o_auth2_server_enabled @o_auth2_server_authorization_url = o_auth2_server_authorization_url @o_auth2_server_scopes = o_auth2_server_scopes @@ -176,7 +185,10 @@ def self.from(map:) blocks: map["blocks"].map { |it| Block.from(map: it) }, console_accessed_at: map["consoleAccessedAt"], waf_enabled: map["wafEnabled"], + parent_id: map["parentId"], billing_limits: map["billingLimits"].nil? ? nil : BillingLimits.from(map: map["billingLimits"]), + first_accessed_at: map["firstAccessedAt"], + mcp_accessed_at: map["mcpAccessedAt"], o_auth2_server_enabled: map["oAuth2ServerEnabled"], o_auth2_server_authorization_url: map["oAuth2ServerAuthorizationUrl"], o_auth2_server_scopes: map["oAuth2ServerScopes"], @@ -227,7 +239,10 @@ def to_map "blocks": @blocks.map { |it| it.to_map }, "consoleAccessedAt": @console_accessed_at, "wafEnabled": @waf_enabled, + "parentId": @parent_id, "billingLimits": @billing_limits&.to_map, + "firstAccessedAt": @first_accessed_at, + "mcpAccessedAt": @mcp_accessed_at, "oAuth2ServerEnabled": @o_auth2_server_enabled, "oAuth2ServerAuthorizationUrl": @o_auth2_server_authorization_url, "oAuth2ServerScopes": @o_auth2_server_scopes, diff --git a/lib/appwrite/models/proxy_rule.rb b/lib/appwrite/models/proxy_rule.rb index adb1cd58..e37a6e6d 100644 --- a/lib/appwrite/models/proxy_rule.rb +++ b/lib/appwrite/models/proxy_rule.rb @@ -99,6 +99,7 @@ def validate_deployment_resource_type(deployment_resource_type) valid_deployment_resource_type = [ Appwrite::Enums::ProxyRuleDeploymentResourceType::FUNCTION, Appwrite::Enums::ProxyRuleDeploymentResourceType::SITE, + Appwrite::Enums::ProxyRuleDeploymentResourceType::DEDICATEDDATABASE, ] unless valid_deployment_resource_type.include?(deployment_resource_type) diff --git a/lib/appwrite/models/topic.rb b/lib/appwrite/models/topic.rb index 4034f4b3..247284d8 100644 --- a/lib/appwrite/models/topic.rb +++ b/lib/appwrite/models/topic.rb @@ -11,6 +11,8 @@ class Topic attr_reader :sms_total attr_reader :push_total attr_reader :subscribe + attr_reader :qos + attr_reader :expiry def initialize( id:, @@ -20,7 +22,9 @@ def initialize( email_total:, sms_total:, push_total:, - subscribe: + subscribe:, + qos:, + expiry: ) @id = id @created_at = created_at @@ -30,6 +34,8 @@ def initialize( @sms_total = sms_total @push_total = push_total @subscribe = subscribe + @qos = qos + @expiry = expiry end def self.from(map:) @@ -41,7 +47,9 @@ def self.from(map:) email_total: map["emailTotal"], sms_total: map["smsTotal"], push_total: map["pushTotal"], - subscribe: map["subscribe"] + subscribe: map["subscribe"], + qos: map["qos"], + expiry: map["expiry"] ) end @@ -54,7 +62,9 @@ def to_map "emailTotal": @email_total, "smsTotal": @sms_total, "pushTotal": @push_total, - "subscribe": @subscribe + "subscribe": @subscribe, + "qos": @qos, + "expiry": @expiry } end end diff --git a/lib/appwrite/models/user.rb b/lib/appwrite/models/user.rb index aa133c24..9586ee8c 100644 --- a/lib/appwrite/models/user.rb +++ b/lib/appwrite/models/user.rb @@ -22,6 +22,7 @@ class User attr_reader :email_is_disposable attr_reader :email_is_corporate attr_reader :email_is_canonical + attr_reader :password_pwned attr_reader :phone_verification attr_reader :mfa attr_reader :prefs @@ -50,6 +51,7 @@ def initialize( email_is_disposable:, email_is_corporate:, email_is_canonical:, + password_pwned:, phone_verification:, mfa:, prefs:, @@ -77,6 +79,7 @@ def initialize( @email_is_disposable = email_is_disposable @email_is_corporate = email_is_corporate @email_is_canonical = email_is_canonical + @password_pwned = password_pwned @phone_verification = phone_verification @mfa = mfa @prefs = prefs @@ -107,6 +110,7 @@ def self.from(map:) email_is_disposable: map["emailIsDisposable"], email_is_corporate: map["emailIsCorporate"], email_is_canonical: map["emailIsCanonical"], + password_pwned: map["passwordPwned"], phone_verification: map["phoneVerification"], mfa: map["mfa"], prefs: Preferences.from(map: map["prefs"]), @@ -138,6 +142,7 @@ def to_map "emailIsDisposable": @email_is_disposable, "emailIsCorporate": @email_is_corporate, "emailIsCanonical": @email_is_canonical, + "passwordPwned": @password_pwned, "phoneVerification": @phone_verification, "mfa": @mfa, "prefs": @prefs.to_map, diff --git a/lib/appwrite/models/waf_rule_bypass.rb b/lib/appwrite/models/waf_rule_bypass.rb new file mode 100644 index 00000000..c7806d55 --- /dev/null +++ b/lib/appwrite/models/waf_rule_bypass.rb @@ -0,0 +1,111 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class WafRuleBypass + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :description + attr_reader :team_id + attr_reader :project_id + attr_reader :resource_type + attr_reader :resource_id + attr_reader :action + attr_reader :priority + attr_reader :enabled + attr_reader :conditions + attr_reader :config + + def initialize( + id:, + created_at:, + updated_at:, + name:, + description:, + team_id:, + project_id:, + resource_type:, + resource_id:, + action:, + priority:, + enabled:, + conditions:, + config: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @description = description + @team_id = team_id + @project_id = project_id + @resource_type = resource_type + @resource_id = resource_id + @action = validate_action(action) + @priority = priority + @enabled = enabled + @conditions = conditions + @config = config + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "description" => "", "teamId" => "", "projectId" => "", "resourceType" => "api", "resourceId" => "", "priority" => 0, "enabled" => true, "conditions" => [], "config" => {} }.merge(map) + WafRuleBypass.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + description: map["description"], + team_id: map["teamId"], + project_id: map["projectId"], + resource_type: map["resourceType"], + resource_id: map["resourceId"], + action: map["action"], + priority: map["priority"], + enabled: map["enabled"], + conditions: map["conditions"], + config: map["config"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "description": @description, + "teamId": @team_id, + "projectId": @project_id, + "resourceType": @resource_type, + "resourceId": @resource_id, + "action": @action, + "priority": @priority, + "enabled": @enabled, + "conditions": @conditions, + "config": @config + } + end + + private + + def validate_action(action) + valid_action = [ + Appwrite::Enums::WafRuleAction::BYPASS, + Appwrite::Enums::WafRuleAction::DENY, + Appwrite::Enums::WafRuleAction::CHALLENGE, + Appwrite::Enums::WafRuleAction::RATELIMIT, + Appwrite::Enums::WafRuleAction::REDIRECT, + ] + + unless valid_action.include?(action) + raise ArgumentError, "Invalid " + action + ". Must be one of: " + valid_action.join(', ') + end + + action + end + end + end +end diff --git a/lib/appwrite/models/waf_rule_challenge.rb b/lib/appwrite/models/waf_rule_challenge.rb new file mode 100644 index 00000000..1fc48b29 --- /dev/null +++ b/lib/appwrite/models/waf_rule_challenge.rb @@ -0,0 +1,126 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class WafRuleChallenge + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :description + attr_reader :team_id + attr_reader :project_id + attr_reader :resource_type + attr_reader :resource_id + attr_reader :action + attr_reader :priority + attr_reader :enabled + attr_reader :conditions + attr_reader :config + attr_reader :challenge_type + attr_reader :difficulty + attr_reader :ttl + + def initialize( + id:, + created_at:, + updated_at:, + name:, + description:, + team_id:, + project_id:, + resource_type:, + resource_id:, + action:, + priority:, + enabled:, + conditions:, + config:, + challenge_type:, + difficulty:, + ttl: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @description = description + @team_id = team_id + @project_id = project_id + @resource_type = resource_type + @resource_id = resource_id + @action = validate_action(action) + @priority = priority + @enabled = enabled + @conditions = conditions + @config = config + @challenge_type = challenge_type + @difficulty = difficulty + @ttl = ttl + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "description" => "", "teamId" => "", "projectId" => "", "resourceType" => "api", "resourceId" => "", "priority" => 0, "enabled" => true, "conditions" => [], "config" => {}, "challengeType" => "compute", "difficulty" => 3, "ttl" => 1800 }.merge(map) + WafRuleChallenge.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + description: map["description"], + team_id: map["teamId"], + project_id: map["projectId"], + resource_type: map["resourceType"], + resource_id: map["resourceId"], + action: map["action"], + priority: map["priority"], + enabled: map["enabled"], + conditions: map["conditions"], + config: map["config"], + challenge_type: map["challengeType"], + difficulty: map["difficulty"], + ttl: map["ttl"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "description": @description, + "teamId": @team_id, + "projectId": @project_id, + "resourceType": @resource_type, + "resourceId": @resource_id, + "action": @action, + "priority": @priority, + "enabled": @enabled, + "conditions": @conditions, + "config": @config, + "challengeType": @challenge_type, + "difficulty": @difficulty, + "ttl": @ttl + } + end + + private + + def validate_action(action) + valid_action = [ + Appwrite::Enums::WafRuleAction::BYPASS, + Appwrite::Enums::WafRuleAction::DENY, + Appwrite::Enums::WafRuleAction::CHALLENGE, + Appwrite::Enums::WafRuleAction::RATELIMIT, + Appwrite::Enums::WafRuleAction::REDIRECT, + ] + + unless valid_action.include?(action) + raise ArgumentError, "Invalid " + action + ". Must be one of: " + valid_action.join(', ') + end + + action + end + end + end +end diff --git a/lib/appwrite/models/waf_rule_deny.rb b/lib/appwrite/models/waf_rule_deny.rb new file mode 100644 index 00000000..4522a155 --- /dev/null +++ b/lib/appwrite/models/waf_rule_deny.rb @@ -0,0 +1,111 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class WafRuleDeny + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :description + attr_reader :team_id + attr_reader :project_id + attr_reader :resource_type + attr_reader :resource_id + attr_reader :action + attr_reader :priority + attr_reader :enabled + attr_reader :conditions + attr_reader :config + + def initialize( + id:, + created_at:, + updated_at:, + name:, + description:, + team_id:, + project_id:, + resource_type:, + resource_id:, + action:, + priority:, + enabled:, + conditions:, + config: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @description = description + @team_id = team_id + @project_id = project_id + @resource_type = resource_type + @resource_id = resource_id + @action = validate_action(action) + @priority = priority + @enabled = enabled + @conditions = conditions + @config = config + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "description" => "", "teamId" => "", "projectId" => "", "resourceType" => "api", "resourceId" => "", "priority" => 0, "enabled" => true, "conditions" => [], "config" => {} }.merge(map) + WafRuleDeny.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + description: map["description"], + team_id: map["teamId"], + project_id: map["projectId"], + resource_type: map["resourceType"], + resource_id: map["resourceId"], + action: map["action"], + priority: map["priority"], + enabled: map["enabled"], + conditions: map["conditions"], + config: map["config"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "description": @description, + "teamId": @team_id, + "projectId": @project_id, + "resourceType": @resource_type, + "resourceId": @resource_id, + "action": @action, + "priority": @priority, + "enabled": @enabled, + "conditions": @conditions, + "config": @config + } + end + + private + + def validate_action(action) + valid_action = [ + Appwrite::Enums::WafRuleAction::BYPASS, + Appwrite::Enums::WafRuleAction::DENY, + Appwrite::Enums::WafRuleAction::CHALLENGE, + Appwrite::Enums::WafRuleAction::RATELIMIT, + Appwrite::Enums::WafRuleAction::REDIRECT, + ] + + unless valid_action.include?(action) + raise ArgumentError, "Invalid " + action + ". Must be one of: " + valid_action.join(', ') + end + + action + end + end + end +end diff --git a/lib/appwrite/models/waf_rule_list.rb b/lib/appwrite/models/waf_rule_list.rb new file mode 100644 index 00000000..ace17d27 --- /dev/null +++ b/lib/appwrite/models/waf_rule_list.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class WafRuleList + attr_reader :total + attr_reader :rules + + def initialize( + total:, + rules: + ) + @total = total + @rules = rules + end + + def self.from(map:) + map = { "total" => 0, "rules" => [] }.merge(map) + WafRuleList.new( + total: map["total"], + rules: map["rules"] + ) + end + + def to_map + { + "total": @total, + "rules": @rules + } + end + end + end +end diff --git a/lib/appwrite/models/waf_rule_rate_limit.rb b/lib/appwrite/models/waf_rule_rate_limit.rb new file mode 100644 index 00000000..1b6288d2 --- /dev/null +++ b/lib/appwrite/models/waf_rule_rate_limit.rb @@ -0,0 +1,136 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class WafRuleRateLimit + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :description + attr_reader :team_id + attr_reader :project_id + attr_reader :resource_type + attr_reader :resource_id + attr_reader :action + attr_reader :priority + attr_reader :enabled + attr_reader :conditions + attr_reader :config + attr_reader :limit + attr_reader :interval + attr_reader :key + attr_reader :strategy + attr_reader :max_bucket_size + + def initialize( + id:, + created_at:, + updated_at:, + name:, + description:, + team_id:, + project_id:, + resource_type:, + resource_id:, + action:, + priority:, + enabled:, + conditions:, + config:, + limit:, + interval:, + key:, + strategy:, + max_bucket_size: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @description = description + @team_id = team_id + @project_id = project_id + @resource_type = resource_type + @resource_id = resource_id + @action = validate_action(action) + @priority = priority + @enabled = enabled + @conditions = conditions + @config = config + @limit = limit + @interval = interval + @key = key + @strategy = strategy + @max_bucket_size = max_bucket_size + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "description" => "", "teamId" => "", "projectId" => "", "resourceType" => "api", "resourceId" => "", "priority" => 0, "enabled" => true, "conditions" => [], "config" => {}, "limit" => 100, "interval" => 3600, "key" => "ip", "strategy" => "fixedWindow", "maxBucketSize" => 0 }.merge(map) + WafRuleRateLimit.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + description: map["description"], + team_id: map["teamId"], + project_id: map["projectId"], + resource_type: map["resourceType"], + resource_id: map["resourceId"], + action: map["action"], + priority: map["priority"], + enabled: map["enabled"], + conditions: map["conditions"], + config: map["config"], + limit: map["limit"], + interval: map["interval"], + key: map["key"], + strategy: map["strategy"], + max_bucket_size: map["maxBucketSize"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "description": @description, + "teamId": @team_id, + "projectId": @project_id, + "resourceType": @resource_type, + "resourceId": @resource_id, + "action": @action, + "priority": @priority, + "enabled": @enabled, + "conditions": @conditions, + "config": @config, + "limit": @limit, + "interval": @interval, + "key": @key, + "strategy": @strategy, + "maxBucketSize": @max_bucket_size + } + end + + private + + def validate_action(action) + valid_action = [ + Appwrite::Enums::WafRuleAction::BYPASS, + Appwrite::Enums::WafRuleAction::DENY, + Appwrite::Enums::WafRuleAction::CHALLENGE, + Appwrite::Enums::WafRuleAction::RATELIMIT, + Appwrite::Enums::WafRuleAction::REDIRECT, + ] + + unless valid_action.include?(action) + raise ArgumentError, "Invalid " + action + ". Must be one of: " + valid_action.join(', ') + end + + action + end + end + end +end diff --git a/lib/appwrite/models/waf_rule_redirect.rb b/lib/appwrite/models/waf_rule_redirect.rb new file mode 100644 index 00000000..a3b5a842 --- /dev/null +++ b/lib/appwrite/models/waf_rule_redirect.rb @@ -0,0 +1,121 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class WafRuleRedirect + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :description + attr_reader :team_id + attr_reader :project_id + attr_reader :resource_type + attr_reader :resource_id + attr_reader :action + attr_reader :priority + attr_reader :enabled + attr_reader :conditions + attr_reader :config + attr_reader :location + attr_reader :status_code + + def initialize( + id:, + created_at:, + updated_at:, + name:, + description:, + team_id:, + project_id:, + resource_type:, + resource_id:, + action:, + priority:, + enabled:, + conditions:, + config:, + location:, + status_code: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @description = description + @team_id = team_id + @project_id = project_id + @resource_type = resource_type + @resource_id = resource_id + @action = validate_action(action) + @priority = priority + @enabled = enabled + @conditions = conditions + @config = config + @location = location + @status_code = status_code + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "description" => "", "teamId" => "", "projectId" => "", "resourceType" => "api", "resourceId" => "", "priority" => 0, "enabled" => true, "conditions" => [], "config" => {}, "location" => "/", "statusCode" => 302 }.merge(map) + WafRuleRedirect.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + description: map["description"], + team_id: map["teamId"], + project_id: map["projectId"], + resource_type: map["resourceType"], + resource_id: map["resourceId"], + action: map["action"], + priority: map["priority"], + enabled: map["enabled"], + conditions: map["conditions"], + config: map["config"], + location: map["location"], + status_code: map["statusCode"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "description": @description, + "teamId": @team_id, + "projectId": @project_id, + "resourceType": @resource_type, + "resourceId": @resource_id, + "action": @action, + "priority": @priority, + "enabled": @enabled, + "conditions": @conditions, + "config": @config, + "location": @location, + "statusCode": @status_code + } + end + + private + + def validate_action(action) + valid_action = [ + Appwrite::Enums::WafRuleAction::BYPASS, + Appwrite::Enums::WafRuleAction::DENY, + Appwrite::Enums::WafRuleAction::CHALLENGE, + Appwrite::Enums::WafRuleAction::RATELIMIT, + Appwrite::Enums::WafRuleAction::REDIRECT, + ] + + unless valid_action.include?(action) + raise ArgumentError, "Invalid " + action + ". Must be one of: " + valid_action.join(', ') + end + + action + end + end + end +end diff --git a/lib/appwrite/services/account.rb b/lib/appwrite/services/account.rb index e29464cc..837b7cb8 100644 --- a/lib/appwrite/services/account.rb +++ b/lib/appwrite/services/account.rb @@ -1260,15 +1260,122 @@ def update_recovery( ) end + # Use this endpoint to send a 6-digit password recovery code to the user's + # email address. Unlike + # [createRecovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery), + # this method requires no redirect URL, which makes it suitable for mobile + # and desktop apps that cannot host a recovery page. Learn more about how to + # [complete the recovery + # process](https://appwrite.io/docs/references/cloud/client-web/account#updateRecoveryOTP). + # The code sent to the user's email address is valid for 15 minutes. + # + # Enable the **phrase** parameter to include a randomly generated security + # phrase in both the email and the response. Showing that phrase in your app + # lets the user confirm the email genuinely came from your request, which + # helps protect against phishing. + # + # + # @param [String] email User email. + # @param [] phrase Toggle for security phrase. If enabled, email will be sent with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + # + # @return [Token] + def create_recovery_otp( + email:, + phrase: nil + ) + if email.nil? + raise Appwrite::Exception.new('Missing required parameter: "email"') + end + + api_path = '/account/recovery/otp' + + api_params = { + email: email, + phrase: phrase, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Token + ) + end + + # Use this endpoint to complete the user password recovery process using the + # 6-digit code that was emailed by + # [createRecoveryOTP](https://appwrite.io/docs/references/cloud/client-web/account#createRecoveryOTP). + # Pass the **userId** of the user along with the **secret** code from the + # email and the new **password** to set. If confirmed, this route will return + # a 200 status code, the code is consumed and the user's password is updated. + # + # + # @param [String] user_id User ID. + # @param [String] secret Valid recovery OTP code. + # @param [String] password New user password. Must be between 8 and 256 chars. + # + # @return [Token] + def update_recovery_otp( + user_id:, + secret:, + password: + ) + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if secret.nil? + raise Appwrite::Exception.new('Missing required parameter: "secret"') + end + + if password.nil? + raise Appwrite::Exception.new('Missing required parameter: "password"') + end + + api_path = '/account/recovery/otp' + + api_params = { + userId: user_id, + secret: secret, + password: password, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Token + ) + end + # Get the list of active sessions across different devices for the currently # logged in user. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [SessionList] - def list_sessions() + def list_sessions( + total: nil + ) api_path = '/account/sessions' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -1287,12 +1394,17 @@ def list_sessions() # Delete all sessions from the user account and remove any sessions cookies # from the end client. # + # @param [] current Delete the current session too. Use false to sign out of every other session while staying signed in on this one. # # @return [] - def delete_sessions() + def delete_sessions( + current: nil + ) api_path = '/account/sessions' - api_params = {} + api_params = { + current: current, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -1346,11 +1458,13 @@ def create_anonymous_session() # # @param [String] email User email. # @param [String] password User password. Must be at least 8 chars. + # @param [Integer] duration Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. # # @return [Session] def create_email_password_session( email:, - password: + password:, + duration: nil ) api_path = '/account/sessions/email' @@ -1365,6 +1479,100 @@ def create_email_password_session( api_params = { email: email, password: password, + duration: duration, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Session + ) + end + + # Allow the user to login to their account using an OpenID Connect ID token + # obtained natively from the OAuth2 provider, for example via Google + # Credential Manager on Android or Sign in with Apple on iOS. No browser or + # redirect is involved: the ID token is verified against the provider's + # published signing keys and a session is created in a single request. + # + # Native sign-in is switched on per provider with its nativeEnabled setting. + # It is independent of the browser-based flow's enabled setting, which has no + # effect on this endpoint. The token's audience must match the provider's + # configured client ID or one of its native client IDs; tokens issued for any + # other client ID are rejected. For Sign in with Apple, register your app's + # bundle ID as a native client ID. For Google, the web client ID used by + # Credential Manager is usually the configured client ID; add your Android + # and iOS client IDs as native client IDs if your app requests tokens for + # them. + # + # Pass the raw nonce used when requesting the ID token so it can be validated + # against the token's nonce claim. When signing in with Apple, the nonce is + # required: hash it with SHA-256 before passing it to the Apple SDK, and send + # the raw value here - Apple tokens requested without a nonce are rejected. + # For Google the nonce is optional: it is validated whenever the token + # carries one, and ignored when the provider issued the token without one. + # Apple only returns the user's name on the first authorization, and never + # inside the ID token - capture it on the client and pass it via the name + # parameter. + # + # If there is already an active session, the new session will be attached to + # the logged-in account. If there are no active sessions, the server will + # attempt to look for a user with the same email address as the verified + # email received from the provider and attach the new session to the existing + # user. If no matching user is found - the server will create a new user. + # + # This flow does not return provider refresh tokens. You may pass an access + # token the provider handed your client, along with its lifetime, to store it + # on the session - but Appwrite cannot renew it once it expires. If your app + # needs long-lived access to provider APIs, use the browser-based OAuth2 flow + # instead. + # + # A user is limited to 10 active sessions at a time by default. [Learn more + # about session + # limits](https://appwrite.io/docs/authentication-security#limits). + # + # + # @param [IdTokenProvider] provider OAuth2 provider that issued the ID token. Currently, supported providers are: apple, google. + # @param [String] id_token OpenID Connect ID token (JWT) obtained natively from the provider, for example via Google Credential Manager or Sign in with Apple. + # @param [String] nonce Raw nonce used when requesting the ID token. Required for Apple, and whenever the token carries a nonce claim, which must match it. Ignored when the provider issued the token without a nonce. + # @param [String] access_token Provider access token to store alongside the session for calling provider APIs. Never used for authentication. + # @param [Integer] access_token_expiry Seconds until the provider access token expires, as reported by the provider. Stored so clients can tell when the stored token goes stale. + # @param [String] name User name. Only used when creating a new user and the ID token has no name claim, such as on the first Sign in with Apple authorization. + # + # @return [Session] + def create_id_token_session( + provider:, + id_token:, + nonce: nil, + access_token: nil, + access_token_expiry: nil, + name: nil + ) + if provider.nil? + raise Appwrite::Exception.new('Missing required parameter: "provider"') + end + + if id_token.nil? + raise Appwrite::Exception.new('Missing required parameter: "idToken"') + end + + api_path = '/account/sessions/id-token' + + api_params = { + provider: provider, + idToken: id_token, + nonce: nonce, + accessToken: access_token, + accessTokenExpiry: access_token_expiry, + name: name, } api_headers = { @@ -2125,6 +2333,94 @@ def update_verification( ) end + # Use this endpoint to send a 6-digit verification code to the currently + # logged in user's email address. Unlike + # [createEmailVerification](https://appwrite.io/docs/references/cloud/client-web/account#createEmailVerification), + # this method requires no redirect URL, which makes it suitable for mobile + # and desktop apps that cannot host a verification page. Learn more about how + # to [complete the verification + # process](https://appwrite.io/docs/references/cloud/client-web/account#updateEmailVerificationOTP). + # The code sent to the user's email address is valid for 15 minutes. + # + # Enable the **phrase** parameter to include a randomly generated security + # phrase in both the email and the response. Showing that phrase in your app + # lets the user confirm the email genuinely came from your request, which + # helps protect against phishing. + # + # + # @param [] phrase Toggle for security phrase. If enabled, email will be sent with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + # + # @return [Token] + def create_email_verification_otp( + phrase: nil + ) + api_path = '/account/verifications/email/otp' + + api_params = { + phrase: phrase, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Token + ) + end + + # Use this endpoint to complete the user email verification process using the + # 6-digit code that was emailed by + # [createEmailVerificationOTP](https://appwrite.io/docs/references/cloud/client-web/account#createEmailVerificationOTP). + # Pass the **userId** of the user being verified along with the **secret** + # code from the email. If confirmed, this route will return a 200 status code + # and the code is consumed. + # + # + # @param [String] user_id User ID. + # @param [String] secret Valid verification OTP code. + # + # @return [Token] + def update_email_verification_otp( + user_id:, + secret: + ) + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if secret.nil? + raise Appwrite::Exception.new('Missing required parameter: "secret"') + end + + api_path = '/account/verifications/email/otp' + + api_params = { + userId: user_id, + secret: secret, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Token + ) + end + # Use this endpoint to send a verification SMS to the currently logged in # user. This endpoint is meant for use after updating a user's phone number # using the diff --git a/lib/appwrite/services/avatars.rb b/lib/appwrite/services/avatars.rb index 42f27720..d3ab6a03 100644 --- a/lib/appwrite/services/avatars.rb +++ b/lib/appwrite/services/avatars.rb @@ -346,6 +346,77 @@ def get_photo( ) end + # Update the profile photo of the currently authenticated user. The uploaded + # image takes priority over every other photo source, including OAuth2 + # identity photos, Gravatar, and Libravatar. Updating an already customized + # photo replaces it. The image must be at most 5MB and is sent in a single + # request. + # + # @param [file] file Binary image file of at most 5MB. Allowed file types are png, jpg, jpeg, and webp. + # + # @return [Account] + def update_photo( + file:, + on_progress: nil + ) + if file.nil? + raise Appwrite::Exception.new('Missing required parameter: "file"') + end + + api_path = '/avatars/photo' + + api_params = { + file: file, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'multipart/form-data', + "accept": 'application/json', + } + + id_param_name = nil + param_name = 'file' + + @client.chunked_upload( + path: api_path, + headers: api_headers, + params: api_params, + param_name: param_name, + id_param_name: id_param_name, + on_progress: on_progress, + method: 'PUT', + response_type: Models::Account + ) + end + + # Delete the profile photo of the currently authenticated user and store the + # built-in static placeholder in its place. The placeholder is the user's + # photo from then on, so it takes priority over every other photo source — + # OAuth2 identity photos, Gravatar, Libravatar, and initials — until a new + # photo is uploaded with avatars.updatePhoto. + # + # + # @return [] + def delete_photo() + api_path = '/avatars/photo' + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + end + # Converts a given plain text to a QR code image. You can use the query # parameters to change the size and style of the resulting image. # diff --git a/lib/appwrite/services/databases.rb b/lib/appwrite/services/databases.rb index 414f91cd..c8783184 100644 --- a/lib/appwrite/services/databases.rb +++ b/lib/appwrite/services/databases.rb @@ -97,15 +97,18 @@ def create( # List transactions across all databases. # # @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). + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [TransactionList] def list_transactions( - queries: nil + queries: nil, + total: nil ) api_path = '/databases/transactions' api_params = { queries: queries, + total: total, } api_headers = { diff --git a/lib/appwrite/services/documents_db.rb b/lib/appwrite/services/documents_db.rb index 09237e92..f97888a7 100644 --- a/lib/appwrite/services/documents_db.rb +++ b/lib/appwrite/services/documents_db.rb @@ -119,15 +119,18 @@ def list_specifications() # List transactions across all databases. # # @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). + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [TransactionList] def list_transactions( - queries: nil + queries: nil, + total: nil ) api_path = '/documentsdb/transactions' api_params = { queries: queries, + total: total, } api_headers = { diff --git a/lib/appwrite/services/domains.rb b/lib/appwrite/services/domains.rb new file mode 100644 index 00000000..3493e9e4 --- /dev/null +++ b/lib/appwrite/services/domains.rb @@ -0,0 +1,2318 @@ +# frozen_string_literal: true + +module Appwrite + class Domains < Service + def initialize(client) + @client = client + end + + # List all domains registered for this project. This endpoint supports + # pagination. + # + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as domain name, teamInternalId, expiration, etc. + # @param [String] search Search term to filter your list results. Max length: 256 chars. + # + # @return [DomainsList] + def list( + queries: nil, + search: nil + ) + api_path = '/domains' + + api_params = { + queries: queries, + search: search, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DomainsList + ) + end + + # Create a new domain. Before creating a domain, you need to ensure that your + # DNS provider is properly configured. After creating the domain, you can use + # the verification endpoint to check if the domain is ready to be used. + # + # @param [String] team_id Team unique ID. + # @param [String] domain Domain name (e.g. "example.com"). + # + # @return [Domain] + def create( + team_id:, + domain: + ) + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + + if domain.nil? + raise Appwrite::Exception.new('Missing required parameter: "domain"') + end + + api_path = '/domains' + + api_params = { + teamId: team_id, + domain: domain, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Domain + ) + end + + # + # @deprecated This API has been deprecated since 2.0.0. Please use `Domains.listPrices` instead. + # + # Get the registration price for a domain name. + # + # @param [String] domain Domain name to get price for. + # @param [Integer] period_years Number of years to calculate the domain price for. Must be at least 1. + # @param [DomainRegistrationType] registration_type Type of registration pricing to fetch. Allowed values: new, transfer, renewal, trade. + # + # @return [DomainPrice] + def get_price( + domain:, + period_years: nil, + registration_type: nil + ) + if domain.nil? + raise Appwrite::Exception.new('Missing required parameter: "domain"') + end + + api_path = '/domains/price' + + api_params = { + domain: domain, + periodYears: period_years, + registrationType: registration_type, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DomainPrice + ) + end + + # Check availability and get the requested registration price for one or more + # domain names. Availability is resolved for all domains in a single + # registrar lookup. Unavailable domains have a null price for new + # registrations, but can still be priced for renewal, transfer, or trade. + # Every priced domain also carries its renewal price for the same period, so + # a separate renewal lookup is not needed. A domain whose price could not be + # resolved, for example because its TLD is not supported, is returned with a + # null price. + # + # @param [Array] domains Domain names to check availability and price for. Maximum of 50 domains per request. + # @param [Integer] period_years Number of years to calculate the domain price for. Must be at least 1. + # @param [DomainRegistrationType] registration_type Type of registration pricing to fetch. Allowed values: new, transfer, renewal, trade. + # + # @return [DomainPricesList] + def list_prices( + domains:, + period_years: nil, + registration_type: nil + ) + if domains.nil? + raise Appwrite::Exception.new('Missing required parameter: "domains"') + end + + api_path = '/domains/prices' + + api_params = { + domains: domains, + periodYears: period_years, + registrationType: registration_type, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DomainPricesList + ) + end + + # Get a domain by its unique ID. + # + # @param [String] domain_id Domain unique ID. + # + # @return [Domain] + def get( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Domain + ) + end + + # Delete a domain by its unique ID. This endpoint can be used to delete a + # domain from your project. + # Once deleted, the domain will no longer be available for use and all + # associated resources will be removed. + # + # @param [String] domain_id Domain unique ID. + # + # @return [] + def delete( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + end + + # Update the registrar nameservers for the given domain. When nameservers are + # not provided, + # the domain will be updated to use Appwrite nameservers. + # + # @param [String] domain_id Domain unique ID. + # @param [Array] nameservers Nameservers to set for the domain. Defaults to Appwrite nameservers when omitted. + # + # @return [Domain] + def update_nameservers( + domain_id:, + nameservers: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/nameservers' + .gsub('{domainId}', domain_id) + + api_params = { + nameservers: nameservers, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Domain + ) + end + + # Verify which NS records are used and update the domain accordingly. This + # will check the domain's + # nameservers and update the domain's status based on whether the nameservers + # match the expected + # Appwrite nameservers. + # + # @param [String] domain_id Domain unique ID. + # + # @return [Domain] + def verify_nameservers( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/nameservers/verification' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Domain + ) + end + + # List Google Workspace DNS records. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def get_preset_google_workspace( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/google-workspace' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # Add Google Workspace DNS records to the domain. This will create the + # required MX records + # for Google Workspace email hosting. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def create_preset_google_workspace( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/google-workspace' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # List iCloud DNS records. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def get_preset_i_cloud( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/icloud' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # Add iCloud DNS records to the domain. This will create the required MX and + # SPF records + # for using iCloud email services with your domain. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def create_preset_i_cloud( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/icloud' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # List Mailgun DNS records. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def get_preset_mailgun( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/mailgun' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # Add Mailgun DNS records to the domain. This endpoint will create the + # required DNS records + # for Mailgun in the specified domain. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def create_preset_mailgun( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/mailgun' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # List Outlook DNS records. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def get_preset_outlook( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/outlook' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # Add Outlook DNS records to the domain. This will create the required MX + # records + # for setting up Outlook email hosting for your domain. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def create_preset_outlook( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/outlook' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # List ProtonMail DNS records. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def get_preset_proton_mail( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/proton-mail' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # Add ProtonMail DNS records to the domain. This will create the required MX + # records + # for using ProtonMail with your custom domain. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def create_preset_proton_mail( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/proton-mail' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # List Zoho DNS records. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def get_preset_zoho( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/zoho' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # Add Zoho Mail DNS records to the domain. This will create the required MX + # records + # for setting up Zoho Mail on your domain. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def create_preset_zoho( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/zoho' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # List DNS records for a given domain. You can use this endpoint to list all + # the DNS records + # associated with your domain. + # + # @param [String] domain_id Domain unique ID. + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. You may filter on attributes such as type, name, value, etc. Maximum of 100 queries are allowed, each 4096 characters long. + # + # @return [DnsRecordsList] + def list_records( + domain_id:, + queries: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/records' + .gsub('{domainId}', domain_id) + + api_params = { + queries: queries, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # Create a new A record for the given domain. A records are used to point a + # domain name + # to an IPv4 address. The record value should be a valid IPv4 address. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value IPv4 address for this A record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment explaining what this record is for. + # + # @return [DnsRecord] + def create_record_a( + domain_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/a' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing A record for the given domain. This endpoint allows you + # to modify + # the properties of an A record including its name (subdomain), IPv4 address, + # TTL, + # and optional comment. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value IPv4 address for this A record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment explaining what this record is for. + # + # @return [DnsRecord] + def update_record_a( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/a/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new AAAA record for the given domain. This endpoint allows you to + # add a new IPv6 DNS record + # to your domain. The record will be used to point a hostname to an IPv6 + # address. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value IPv6 address for this AAAA record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment explaining what this record is for. + # + # @return [DnsRecord] + def create_record_aaaa( + domain_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/aaaa' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing AAAA record for the given domain. This endpoint allows + # you to modify + # the properties of an existing AAAA record, including its name (subdomain), + # IPv6 address, + # TTL, and optional comment. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value IPv6 address for this AAAA record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_aaaa( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/aaaa/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new ALIAS record for the given domain. This record type can be + # used to point your domain + # to another domain name that will serve as an alias. This is particularly + # useful when you want to + # map your domain to a target domain that may change its IP address. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name. + # @param [String] value Target domain for this ALIAS record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_alias( + domain_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/alias' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing ALIAS record for the specified domain. This endpoint + # allows you to modify + # the properties of an existing ALIAS record including its name, target + # domain, TTL, and comment. + # + # The ALIAS record type is similar to a CNAME record but can be used at the + # zone apex (root domain). + # It provides a way to map one domain name to another. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name. + # @param [String] value Target domain for this ALIAS record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_alias( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/alias/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new CAA record for the given domain. CAA records are used to + # specify which + # Certificate Authorities (CAs) are allowed to issue SSL/TLS certificates for + # your domain. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name. + # @param [String] value CAA value (e.g. issuer domain). + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_caa( + domain_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/caa' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing CAA record for the given domain. A CAA (Certification + # Authority Authorization) + # record is used to specify which certificate authorities (CAs) are + # authorized to issue certificates + # for a domain. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name. + # @param [String] value CAA value (e.g. issuer domain). + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_caa( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/caa/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new CNAME record for the given domain. + # + # A CNAME record maps a subdomain to another domain name, allowing you to + # create aliases + # for your domain. For example, you can create a CNAME record to point + # 'blog.example.com' + # to 'example.wordpress.com'. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Canonical target for this CNAME record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_cname( + domain_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/cname' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing CNAME record for the given domain. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Canonical target for this CNAME record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_cname( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/cname/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new HTTPS record for the given domain. This record is used to + # configure HTTPS + # settings for your domain, enabling secure communication over SSL/TLS. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Target for the HTTPS record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_https( + domain_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/https' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing HTTPS record for the given domain. This endpoint allows + # you to modify + # the properties of an HTTPS record associated with your domain, including + # the name (subdomain), + # target value, TTL, and optional comment. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Target for the HTTPS record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_https( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/https/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new MX record for the given domain. MX records are used to define + # the mail servers responsible + # for accepting email messages for the domain. Multiple MX records can be + # created with different priorities. + # The priority parameter determines the order in which mail servers are used, + # with lower values indicating + # higher priority. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Mail server domain for this MX record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [Integer] priority MX priority. Lower values are tried first. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_mx( + domain_id:, + name:, + value:, + ttl:, + priority:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + if priority.nil? + raise Appwrite::Exception.new('Missing required parameter: "priority"') + end + + api_path = '/domains/{domainId}/records/mx' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + priority: priority, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing MX record for the given domain. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Mail server domain for this MX record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [Integer] priority MX priority. Lower values are tried first. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_mx( + domain_id:, + record_id:, + name:, + value:, + ttl:, + priority:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + if priority.nil? + raise Appwrite::Exception.new('Missing required parameter: "priority"') + end + + api_path = '/domains/{domainId}/records/mx/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + priority: priority, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new NS record for the given domain. NS records specify the + # nameservers that are used + # to resolve the domain name to IP addresses. Each domain can have multiple + # NS records. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Nameserver target for this NS record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_ns( + domain_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/ns' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing NS record for the given domain. This endpoint allows you + # to modify + # the properties of an NS (nameserver) record associated with your domain. + # You can update + # the record name (subdomain), target nameserver value, TTL, and add or + # modify comments + # for better record management. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Nameserver target for this NS record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_ns( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/ns/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new SRV record for the given domain. SRV records are used to + # define the location + # of servers for specific services. For example, they can be used to specify + # which server + # handles a specific service like SIP or XMPP for the domain. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (service name). + # @param [String] value Target hostname for this SRV record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [Integer] priority Record priority. Lower values are tried first. + # @param [Integer] weight Record weight, used to share load between targets of equal priority. + # @param [Integer] port Port number for the service. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_srv( + domain_id:, + name:, + value:, + ttl:, + priority:, + weight:, + port:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + if priority.nil? + raise Appwrite::Exception.new('Missing required parameter: "priority"') + end + + if weight.nil? + raise Appwrite::Exception.new('Missing required parameter: "weight"') + end + + if port.nil? + raise Appwrite::Exception.new('Missing required parameter: "port"') + end + + api_path = '/domains/{domainId}/records/srv' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + priority: priority, + weight: weight, + port: port, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing SRV record for the given domain. + # + # Required parameters: + # - domainId: Domain unique ID + # - recordId: DNS record unique ID + # - name: Record name (service name) + # - value: Target hostname for this SRV record + # - ttl: Time to live, in seconds + # - priority: Record priority + # - weight: Record weight + # - port: Port number for the service + # + # Optional parameters: + # - comment: A comment for this record + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (service name). + # @param [String] value Target hostname for this SRV record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [Integer] priority Record priority. Lower values are tried first. + # @param [Integer] weight Record weight, used to share load between targets of equal priority. + # @param [Integer] port Port number for the service. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_srv( + domain_id:, + record_id:, + name:, + value:, + ttl:, + priority:, + weight:, + port:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + if priority.nil? + raise Appwrite::Exception.new('Missing required parameter: "priority"') + end + + if weight.nil? + raise Appwrite::Exception.new('Missing required parameter: "weight"') + end + + if port.nil? + raise Appwrite::Exception.new('Missing required parameter: "port"') + end + + api_path = '/domains/{domainId}/records/srv/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + priority: priority, + weight: weight, + port: port, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new TXT record for the given domain. TXT records can be used + # to provide additional information about your domain, such as domain + # verification records, SPF records, or DKIM records. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (subdomain) for the TXT record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] value TXT record value. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_txt( + domain_id:, + name:, + ttl:, + value: nil, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/txt' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing TXT record for the given domain. + # + # Update the TXT record details for a specific domain by providing the domain + # ID, + # record ID, and the new record configuration including name, value, TTL, and + # an optional comment. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (subdomain) for the TXT record. + # @param [String] value TXT record value. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_txt( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/txt/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Get a single DNS record for a given domain by record ID. + # + # This endpoint allows you to retrieve a specific DNS record associated with + # a domain + # using its unique identifier. The record contains information about the DNS + # configuration + # such as type, value, and TTL settings. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # + # @return [DnsRecord] + def get_record( + domain_id:, + record_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + api_path = '/domains/{domainId}/records/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Delete a DNS record for the given domain. This endpoint allows you to + # delete an existing DNS record + # from a specific domain. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # + # @return [] + def delete_record( + domain_id:, + record_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + api_path = '/domains/{domainId}/records/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + end + + # Update the team ID for a specific domain. The caller must administer the + # current + # team and be an owner of the destination team. + # + # Updating the team ID will transfer ownership and access control of the + # domain + # and all its DNS records to the new team. + # + # @param [String] domain_id Domain unique ID. + # @param [String] team_id New team unique ID. + # + # @return [Domain] + def update_team( + domain_id:, + team_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + + api_path = '/domains/{domainId}/team' + .gsub('{domainId}', domain_id) + + api_params = { + teamId: team_id, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Domain + ) + end + + # Retrieve the current transfer status for a domain. Returns the status, an + # optional reason, and a timestamp of the last status change. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DomainTransferStatus] + def get_transfer_status( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/transfers/status' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DomainTransferStatus + ) + end + + # Retrieve the DNS zone file for the given domain. This endpoint will return + # the DNS + # zone file in a standardized format that can be used to configure DNS + # servers. + # + # @param [String] domain_id Domain unique ID. + # + # @return [String] + def get_zone( + domain_id: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/zone' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'text/plain', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: "text" + ) + end + + # Update the DNS zone for the given domain using the provided zone file + # content. + # All parsed records are imported and then the main domain document is + # returned. + # + # @param [String] domain_id Domain unique ID. + # @param [String] content DNS zone file content as a string. + # + # @return [Domain] + def update_zone( + domain_id:, + content: + ) + if domain_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if content.nil? + raise Appwrite::Exception.new('Missing required parameter: "content"') + end + + api_path = '/domains/{domainId}/zone' + .gsub('{domainId}', domain_id) + + api_params = { + content: content, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Domain + ) + end + end +end diff --git a/lib/appwrite/services/functions.rb b/lib/appwrite/services/functions.rb index 52ceb963..dcf47e0c 100644 --- a/lib/appwrite/services/functions.rb +++ b/lib/appwrite/services/functions.rb @@ -153,12 +153,17 @@ def create( # Get a list of all runtimes that are currently active on your instance. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [RuntimeList] - def list_runtimes() + def list_runtimes( + total: nil + ) api_path = '/functions/runtimes' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -177,15 +182,18 @@ def list_runtimes() # List allowed function specifications for this instance. # # @param [String] type Specification type to list. Can be one of: runtimes, builds. Defaults to runtimes. + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [SpecificationList] def list_specifications( - type: nil + type: nil, + total: nil ) api_path = '/functions/specifications' api_params = { type: type, + total: total, } api_headers = { diff --git a/lib/appwrite/services/locale.rb b/lib/appwrite/services/locale.rb index 3728751b..8a50531a 100644 --- a/lib/appwrite/services/locale.rb +++ b/lib/appwrite/services/locale.rb @@ -37,12 +37,17 @@ def get() # List of all locale codes in [ISO # 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [LocaleCodeList] - def list_codes() + def list_codes( + total: nil + ) api_path = '/locale/codes' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -61,12 +66,17 @@ def list_codes() # List of all continents. You can use the locale header to get the data in a # supported language. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [ContinentList] - def list_continents() + def list_continents( + total: nil + ) api_path = '/locale/continents' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -85,12 +95,17 @@ def list_continents() # List of all countries. You can use the locale header to get the data in a # supported language. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [CountryList] - def list_countries() + def list_countries( + total: nil + ) api_path = '/locale/countries' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -109,12 +124,17 @@ def list_countries() # List of all countries that are currently members of the EU. You can use the # locale header to get the data in a supported language. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [CountryList] - def list_countries_eu() + def list_countries_eu( + total: nil + ) api_path = '/locale/countries/eu' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -133,12 +153,17 @@ def list_countries_eu() # List of all countries phone codes. You can use the locale header to get the # data in a supported language. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [PhoneList] - def list_countries_phones() + def list_countries_phones( + total: nil + ) api_path = '/locale/countries/phones' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -158,12 +183,17 @@ def list_countries_phones() # decimal digits for all major and minor currencies. You can use the locale # header to get the data in a supported language. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [CurrencyList] - def list_currencies() + def list_currencies( + total: nil + ) api_path = '/locale/currencies' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -182,12 +212,17 @@ def list_currencies() # List of all languages classified by ISO 639-1 including 2-letter code, name # in English, and name in the respective language. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [LanguageList] - def list_languages() + def list_languages( + total: nil + ) api_path = '/locale/languages' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), diff --git a/lib/appwrite/services/messaging.rb b/lib/appwrite/services/messaging.rb index 30ab729f..ab97d81c 100644 --- a/lib/appwrite/services/messaging.rb +++ b/lib/appwrite/services/messaging.rb @@ -54,6 +54,8 @@ def list_messages( # @param [] draft Is message a draft # @param [] html Is content of type HTML # @param [String] scheduled_at Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + # @param [String] reply_to_email Email address to reply to. If not set, defaults to the sender email address. + # @param [String] reply_to_name Name of the reply to recipient. If not set, defaults to the sender name. # # @return [Message] def create_email( @@ -68,7 +70,9 @@ def create_email( attachments: nil, draft: nil, html: nil, - scheduled_at: nil + scheduled_at: nil, + reply_to_email: nil, + reply_to_name: nil ) api_path = '/messaging/messages/email' @@ -97,6 +101,8 @@ def create_email( draft: draft, html: html, scheduledAt: scheduled_at, + replyToEmail: reply_to_email, + replyToName: reply_to_name, } api_headers = { @@ -131,6 +137,8 @@ def create_email( # @param [Array] bcc Array of target IDs to be added as BCC. # @param [String] scheduled_at Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. # @param [Array] attachments Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + # @param [String] reply_to_email Email address to reply to. Pass an empty string to restore the provider or sender default. + # @param [String] reply_to_name Name of the reply to recipient. Pass an empty string to restore the provider or sender default. # # @return [Message] def update_email( @@ -145,7 +153,9 @@ def update_email( cc: nil, bcc: nil, scheduled_at: nil, - attachments: nil + attachments: nil, + reply_to_email: nil, + reply_to_name: nil ) api_path = '/messaging/messages/email/{messageId}' .gsub('{messageId}', message_id) @@ -166,6 +176,8 @@ def update_email( bcc: bcc, scheduledAt: scheduled_at, attachments: attachments, + replyToEmail: reply_to_email, + replyToName: reply_to_name, } api_headers = { @@ -204,6 +216,7 @@ def update_email( # @param [] content_available If set to true, the notification will be delivered in the background. Available only for iOS Platform. # @param [] critical If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. # @param [MessagePriority] priority Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. + # @param [String] channel_id ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Available only for Android Platform. # # @return [Message] def create_push( @@ -225,7 +238,8 @@ def create_push( scheduled_at: nil, content_available: nil, critical: nil, - priority: nil + priority: nil, + channel_id: nil ) api_path = '/messaging/messages/push' @@ -253,6 +267,7 @@ def create_push( contentAvailable: content_available, critical: critical, priority: priority, + channelId: channel_id, } api_headers = { @@ -294,6 +309,7 @@ def create_push( # @param [] content_available If set to true, the notification will be delivered in the background. Available only for iOS Platform. # @param [] critical If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. # @param [MessagePriority] priority Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + # @param [String] channel_id ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. # # @return [Message] def update_push( @@ -315,7 +331,8 @@ def update_push( scheduled_at: nil, content_available: nil, critical: nil, - priority: nil + priority: nil, + channel_id: nil ) api_path = '/messaging/messages/push/{messageId}' .gsub('{messageId}', message_id) @@ -343,6 +360,7 @@ def update_push( contentAvailable: content_available, critical: critical, priority: priority, + channelId: channel_id, } api_headers = { @@ -716,6 +734,100 @@ def update_apns_provider( ) end + # Create a new Appwrite push provider. + # + # @param [String] provider_id Provider 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 Provider name. + # @param [] enabled Set as enabled. + # @param [Integer] qos Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). + # + # @return [Provider] + def create_appwrite_provider( + provider_id:, + name:, + enabled: nil, + qos: nil, + expiry: nil + ) + if provider_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "providerId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + api_path = '/messaging/providers/appwrite' + + api_params = { + providerId: provider_id, + name: name, + enabled: enabled, + qos: qos, + expiry: expiry, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Provider + ) + end + + # Update an Appwrite push provider by its unique ID. + # + # @param [String] provider_id Provider ID. + # @param [String] name Provider name. + # @param [] enabled Set as enabled. + # @param [Integer] qos Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). + # + # @return [Provider] + def update_appwrite_provider( + provider_id:, + name: nil, + enabled: nil, + qos: nil, + expiry: nil + ) + if provider_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "providerId"') + end + + api_path = '/messaging/providers/appwrite/{providerId}' + .gsub('{providerId}', provider_id) + + api_params = { + name: name, + enabled: enabled, + qos: qos, + expiry: expiry, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Provider + ) + end + # Create a new Firebase Cloud Messaging provider. # # @param [String] provider_id Provider 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. @@ -2029,12 +2141,16 @@ def list_topics( # @param [String] topic_id Topic ID. Choose a custom Topic ID or a new Topic ID. # @param [String] name Topic Name. # @param [Array] subscribe An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + # @param [Integer] qos MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). # # @return [Topic] def create_topic( topic_id:, name:, - subscribe: nil + subscribe: nil, + qos: nil, + expiry: nil ) api_path = '/messaging/topics' @@ -2050,6 +2166,8 @@ def create_topic( topicId: topic_id, name: name, subscribe: subscribe, + qos: qos, + expiry: expiry, } api_headers = { @@ -2105,12 +2223,16 @@ def get_topic( # @param [String] topic_id Topic ID. # @param [String] name Topic Name. # @param [Array] subscribe An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + # @param [Integer] qos MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). # # @return [Topic] def update_topic( topic_id:, name: nil, - subscribe: nil + subscribe: nil, + qos: nil, + expiry: nil ) api_path = '/messaging/topics/{topicId}' .gsub('{topicId}', topic_id) @@ -2122,6 +2244,8 @@ def update_topic( api_params = { name: name, subscribe: subscribe, + qos: qos, + expiry: expiry, } api_headers = { diff --git a/lib/appwrite/services/oauth2.rb b/lib/appwrite/services/oauth2.rb index 0080fe00..33402a28 100644 --- a/lib/appwrite/services/oauth2.rb +++ b/lib/appwrite/services/oauth2.rb @@ -303,6 +303,51 @@ def get_grant( ) end + # Introspect an OAuth2 access token or refresh token. Authenticate with an + # API key holding the `oauth2.introspect` scope to introspect any token in + # the project, or with the client credentials of the app the token was issued + # to. + # + # @param [String] token The access token or refresh token to introspect. + # @param [String] token_type_hint Type of token to introspect. Can be one of: `access_token` or `refresh_token`. + # @param [String] client_id OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + # @param [String] client_secret OAuth2 client secret. + # + # @return [Oauth2Introspection] + def introspect( + token:, + token_type_hint: nil, + client_id: nil, + client_secret: nil + ) + if token.nil? + raise Appwrite::Exception.new('Missing required parameter: "token"') + end + + api_path = '/oauth2/{project_id}/introspect' + .gsub('{project_id}', @client.get_config('project')) + + api_params = { + token: token, + token_type_hint: token_type_hint, + client_id: client_id, + client_secret: client_secret, + } + + api_headers = { + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Oauth2Introspection + ) + end + # List the organizations the OAuth2 access token can access. Resolves the # token's `organization` authorization details, expanding the `*` wildcard # into the concrete set of organizations the user can see. diff --git a/lib/appwrite/services/organization.rb b/lib/appwrite/services/organization.rb index 83c2817d..b43b8f29 100644 --- a/lib/appwrite/services/organization.rb +++ b/lib/appwrite/services/organization.rb @@ -818,5 +818,230 @@ def delete_project( params: api_params, ) end + + # Get a list of all API keys of a project in your organization. + # + # @param [String] project_id Project unique ID. + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. 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_project_keys( + project_id:, + queries: nil, + total: nil + ) + if project_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "projectId"') + end + + api_path = '/organization/projects/{projectId}/keys' + .gsub('{projectId}', project_id) + + api_params = { + queries: queries, + total: total, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::KeyList + ) + end + + # Create a new ephemeral API key for a project in your organization. It's + # recommended to have multiple API keys with strict scopes for separate + # functions within your project. + # + # You can also create a standard API key if you need a longer-lived key + # instead. + # + # @param [String] project_id Project unique ID. + # @param [Array] scopes Key scopes list. Maximum of 200 scopes are allowed. + # @param [Integer] duration Time in seconds before ephemeral key expires. Maximum duration is 3600 seconds. + # + # @return [EphemeralKey] + def create_ephemeral_project_key( + project_id:, + scopes:, + duration: + ) + if project_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "projectId"') + end + + if scopes.nil? + raise Appwrite::Exception.new('Missing required parameter: "scopes"') + end + + if duration.nil? + raise Appwrite::Exception.new('Missing required parameter: "duration"') + end + + api_path = '/organization/projects/{projectId}/keys/ephemeral' + .gsub('{projectId}', project_id) + + api_params = { + scopes: scopes, + duration: duration, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::EphemeralKey + ) + end + + # Get a project key by its unique ID. + # + # @param [String] project_id Project unique ID. + # @param [String] key_id Key ID. + # + # @return [Key] + def get_project_key( + project_id:, + key_id: + ) + if project_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "projectId"') + end + + if key_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "keyId"') + end + + api_path = '/organization/projects/{projectId}/keys/{keyId}' + .gsub('{projectId}', project_id) + .gsub('{keyId}', key_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Key + ) + end + + # Update a project key by its unique ID. Use this endpoint to update the + # name, scopes, or expiration time of an API key. + # + # @param [String] project_id Project unique ID. + # @param [String] key_id Key ID. + # @param [String] name Key name. Max length: 128 chars. + # @param [Array] scopes Key scopes list. Maximum of 200 scopes are allowed. + # @param [String] expire Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + # + # @return [Key] + def update_project_key( + project_id:, + key_id:, + name:, + scopes:, + expire: nil + ) + if project_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "projectId"') + end + + 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_path = '/organization/projects/{projectId}/keys/{keyId}' + .gsub('{projectId}', project_id) + .gsub('{keyId}', key_id) + + api_params = { + name: name, + scopes: scopes, + expire: expire, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Key + ) + end + + # Delete a project key by its unique ID. Once deleted, the key can no longer + # be used to authenticate API calls. + # + # @param [String] project_id Project unique ID. + # @param [String] key_id Key ID. + # + # @return [] + def delete_project_key( + project_id:, + key_id: + ) + if project_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "projectId"') + end + + if key_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "keyId"') + end + + api_path = '/organization/projects/{projectId}/keys/{keyId}' + .gsub('{projectId}', project_id) + .gsub('{keyId}', key_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + end end end diff --git a/lib/appwrite/services/project.rb b/lib/appwrite/services/project.rb index 82389a7f..21ff2eb5 100644 --- a/lib/appwrite/services/project.rb +++ b/lib/appwrite/services/project.rb @@ -91,6 +91,182 @@ def update_auth_method( ) end + # Get a list of all environments of 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, teamId, labels, search, accessedAt, status, parentId + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [ProjectList] + def list_environments( + queries: nil, + total: nil + ) + api_path = '/project/environments' + + api_params = { + queries: queries, + total: total, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::ProjectList + ) + end + + # Create a new environment of the project. An environment is a separate + # project in the same organization and region, with its own resources and + # users. Its usage is billed under the project it belongs to. + # + # @param [String] environment_id Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + # @param [String] name Environment name. Max length: 128 chars. + # + # @return [Project] + def create_environment( + environment_id:, + name: + ) + if environment_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "environmentId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + api_path = '/project/environments' + + api_params = { + environmentId: environment_id, + name: name, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Project + ) + end + + # Get an environment of the project by its unique ID. + # + # @param [String] environment_id Environment unique ID. + # + # @return [Project] + def get_environment( + environment_id: + ) + if environment_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "environmentId"') + end + + api_path = '/project/environments/{environmentId}' + .gsub('{environmentId}', environment_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Project + ) + end + + # Update the name of an environment of the project. + # + # @param [String] environment_id Environment unique ID. + # @param [String] name Environment name. Max length: 128 chars. + # + # @return [Project] + def update_environment( + environment_id:, + name: + ) + if environment_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "environmentId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + api_path = '/project/environments/{environmentId}' + .gsub('{environmentId}', environment_id) + + api_params = { + name: name, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Project + ) + end + + # Delete an environment of the project, with all of its resources and users. + # + # @param [String] environment_id Environment unique ID. + # + # @return [] + def delete_environment( + environment_id: + ) + if environment_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "environmentId"') + end + + api_path = '/project/environments/{environmentId}' + .gsub('{environmentId}', environment_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + end + # 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 @@ -646,7 +822,9 @@ def update_o_auth2_amazon( # @param [String] key_id 'Key ID' of Apple OAuth2 app. For example: P4000000N8 # @param [String] team_id 'Team ID' of Apple OAuth2 app. For example: D4000000R6 # @param [String] p8_file Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # @param [] enabled Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + # @param [Array] native_client_ids App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + # @param [] native_enabled Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. # # @return [OAuth2Apple] def update_o_auth2_apple( @@ -654,7 +832,9 @@ def update_o_auth2_apple( key_id: nil, team_id: nil, p8_file: nil, - enabled: nil + enabled: nil, + native_client_ids: nil, + native_enabled: nil ) api_path = '/project/oauth2/apple' @@ -664,6 +844,8 @@ def update_o_auth2_apple( teamId: team_id, p8File: p8_file, enabled: enabled, + nativeClientIds: native_client_ids, + nativeEnabled: native_enabled, } api_headers = { @@ -722,13 +904,15 @@ def update_o_auth2_appwrite( # @param [String] client_secret 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF # @param [String] endpoint Domain of Auth0 instance. For example: example.us.auth0.com # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # @param [Array] prompt Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. # # @return [OAuth2Auth0] def update_o_auth2_auth0( client_id: nil, client_secret: nil, endpoint: nil, - enabled: nil + enabled: nil, + prompt: nil ) api_path = '/project/oauth2/auth0' @@ -737,6 +921,7 @@ def update_o_auth2_auth0( clientSecret: client_secret, endpoint: endpoint, enabled: enabled, + prompt: prompt, } api_headers = { @@ -1007,12 +1192,14 @@ def update_o_auth2_dailymotion( # @param [String] client_id 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 # @param [String] client_secret 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # @param [Array] prompt Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. # # @return [OAuth2Discord] def update_o_auth2_discord( client_id: nil, client_secret: nil, - enabled: nil + enabled: nil, + prompt: nil ) api_path = '/project/oauth2/discord' @@ -1020,6 +1207,7 @@ def update_o_auth2_discord( clientId: client_id, clientSecret: client_secret, enabled: enabled, + prompt: prompt, } api_headers = { @@ -1255,12 +1443,14 @@ def update_o_auth2_fusion_auth( # @param [String] client_id 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 # @param [String] client_secret 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # @param [Array] prompt Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. # # @return [OAuth2Github] def update_o_auth2_git_hub( client_id: nil, client_secret: nil, - enabled: nil + enabled: nil, + prompt: nil ) api_path = '/project/oauth2/github' @@ -1268,6 +1458,7 @@ def update_o_auth2_git_hub( clientId: client_id, clientSecret: client_secret, enabled: enabled, + prompt: prompt, } api_headers = { @@ -1328,14 +1519,18 @@ def update_o_auth2_gitlab( # @param [String] client_id 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com # @param [String] client_secret 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj # @param [Array] prompt Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # @param [] enabled Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + # @param [Array] native_client_ids Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + # @param [] native_enabled Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. # # @return [OAuth2Google] def update_o_auth2_google( client_id: nil, client_secret: nil, prompt: nil, - enabled: nil + enabled: nil, + native_client_ids: nil, + native_enabled: nil ) api_path = '/project/oauth2/google' @@ -1344,6 +1539,8 @@ def update_o_auth2_google( clientSecret: client_secret, prompt: prompt, enabled: enabled, + nativeClientIds: native_client_ids, + nativeEnabled: native_enabled, } api_headers = { @@ -1396,6 +1593,44 @@ def update_o_auth2_hugging_face( ) end + # Update the project OAuth2 Kakao configuration. + # + # @param [String] client_id 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + # @param [String] client_secret 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + # @param [Array] prompt Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. + # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # + # @return [OAuth2Kakao] + def update_o_auth2_kakao( + client_id: nil, + client_secret: nil, + prompt: nil, + enabled: nil + ) + api_path = '/project/oauth2/kakao' + + api_params = { + clientId: client_id, + clientSecret: client_secret, + prompt: prompt, + enabled: enabled, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::OAuth2Kakao + ) + end + # Update the project OAuth2 Keycloak configuration. # # @param [String] client_id 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app @@ -1513,13 +1748,15 @@ def update_o_auth2_linkedin( # @param [String] application_secret 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u # @param [String] tenant Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # @param [Array] prompt Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. # # @return [OAuth2Microsoft] def update_o_auth2_microsoft( application_id: nil, application_secret: nil, tenant: nil, - enabled: nil + enabled: nil, + prompt: nil ) api_path = '/project/oauth2/microsoft' @@ -1528,6 +1765,7 @@ def update_o_auth2_microsoft( applicationSecret: application_secret, tenant: tenant, enabled: enabled, + prompt: prompt, } api_headers = { @@ -1640,6 +1878,7 @@ def update_o_auth2_oidc( # @param [String] domain Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ # @param [String] authorization_server_id Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # @param [Array] prompt Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. # # @return [OAuth2Okta] def update_o_auth2_okta( @@ -1647,7 +1886,8 @@ def update_o_auth2_okta( client_secret: nil, domain: nil, authorization_server_id: nil, - enabled: nil + enabled: nil, + prompt: nil ) api_path = '/project/oauth2/okta' @@ -1657,6 +1897,7 @@ def update_o_auth2_okta( domain: domain, authorizationServerId: authorization_server_id, enabled: enabled, + prompt: prompt, } api_headers = { @@ -1819,12 +2060,14 @@ def update_o_auth2_resend( # @param [String] customer_key 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq # @param [String] customer_secret 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # @param [Array] prompt Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. # # @return [OAuth2Salesforce] def update_o_auth2_salesforce( customer_key: nil, customer_secret: nil, - enabled: nil + enabled: nil, + prompt: nil ) api_path = '/project/oauth2/salesforce' @@ -1832,6 +2075,7 @@ def update_o_auth2_salesforce( customerKey: customer_key, customerSecret: customer_secret, enabled: enabled, + prompt: prompt, } api_headers = { @@ -1954,6 +2198,41 @@ def update_o_auth2_stripe( ) end + # Update the project OAuth2 TikTok configuration. + # + # @param [String] client_id 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + # @param [String] client_secret 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite + # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # + # @return [OAuth2TikTok] + def update_o_auth2_tik_tok( + client_id: nil, + client_secret: nil, + enabled: nil + ) + api_path = '/project/oauth2/tiktok' + + api_params = { + clientId: client_id, + clientSecret: client_secret, + enabled: enabled, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::OAuth2TikTok + ) + end + # Update the project OAuth2 Tradeshift configuration. # # @param [String] oauth2_client_id 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app @@ -2059,6 +2338,41 @@ def update_o_auth2_twitch( ) end + # Update the project OAuth2 Webflow configuration. + # + # @param [String] client_id 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd + # @param [String] client_secret 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 + # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # + # @return [OAuth2Webflow] + def update_o_auth2_webflow( + client_id: nil, + client_secret: nil, + enabled: nil + ) + api_path = '/project/oauth2/webflow' + + api_params = { + clientId: client_id, + clientSecret: client_secret, + enabled: enabled, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::OAuth2Webflow + ) + end + # Update the project OAuth2 WordPress configuration. # # @param [String] client_id 'Client ID' of WordPress OAuth2 app. For example: 130005 @@ -2204,12 +2518,14 @@ def update_o_auth2_yandex( # @param [String] client_id 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B # @param [String] client_secret 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # @param [Array] prompt Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. # # @return [OAuth2Zoho] def update_o_auth2_zoho( client_id: nil, client_secret: nil, - enabled: nil + enabled: nil, + prompt: nil ) api_path = '/project/oauth2/zoho' @@ -2217,6 +2533,7 @@ def update_o_auth2_zoho( clientId: client_id, clientSecret: client_secret, enabled: enabled, + prompt: prompt, } api_headers = { @@ -2274,7 +2591,7 @@ def update_o_auth2_zoom( # # @param [ProjectOAuthProviderId] provider_id OAuth2 provider key. For example: github, google, apple. # - # @return [OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2HuggingFace, OAuth2Resend, OAuth2Cloudflare, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft] + # @return [OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Webflow, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2HuggingFace, OAuth2Resend, OAuth2Cloudflare, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft, OAuth2TikTok, OAuth2Kakao] def get_o_auth2_provider( provider_id: ) @@ -2378,6 +2695,11 @@ def get_o_auth2_provider( return Models::OAuth2WordPress.from(map: response) end + if response['$id'] == 'webflow' + + return Models::OAuth2Webflow.from(map: response) + end + if response['$id'] == 'twitch' return Models::OAuth2Twitch.from(map: response) @@ -2518,6 +2840,16 @@ def get_o_auth2_provider( return Models::OAuth2Microsoft.from(map: response) end + if response['$id'] == 'tiktok' + + return Models::OAuth2TikTok.from(map: response) + end + + if response['$id'] == 'kakao' + + return Models::OAuth2Kakao.from(map: response) + end + raise Exception, "Unable to match response to any expected response model" end @@ -2560,12 +2892,14 @@ def list_platforms( # @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. + # @param [Array] fingerprints SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. # # @return [PlatformAndroid] def create_android_platform( platform_id:, name:, - application_id: + application_id:, + fingerprints: nil ) api_path = '/project/platforms/android' @@ -2585,6 +2919,7 @@ def create_android_platform( platformId: platform_id, name: name, applicationId: application_id, + fingerprints: fingerprints, } api_headers = { @@ -2608,12 +2943,14 @@ def create_android_platform( # @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. + # @param [Array] fingerprints SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. # # @return [PlatformAndroid] def update_android_platform( platform_id:, name:, - application_id: + application_id:, + fingerprints: nil ) api_path = '/project/platforms/android/{platformId}' .gsub('{platformId}', platform_id) @@ -2633,6 +2970,7 @@ def update_android_platform( api_params = { name: name, applicationId: application_id, + fingerprints: fingerprints, } api_headers = { @@ -3536,6 +3874,82 @@ def update_password_personal_data_policy( ) end + # Updating this policy allows you to control if passwords are checked against + # the Have I Been Pwned breach database. When enabled, every password a user + # signs up, signs in or resets with is checked and the result is recorded on + # the user as `passwordPwned`. On its own the policy only records. Enable + # `users` to reject a breached password when a user signs up or sets a new + # password, and `sessions` to refuse a sign-in with a breached password until + # it is reset. Only the first five characters of the password hash are ever + # shared with the service. Options left out keep their current value. + # + # @param [] enabled Toggle password pwned policy. Set to true to check passwords against known data breaches and record the result on the user, or false to never check. Default is true. On its own this only records; use `users` and `sessions` to block. When changing this policy, existing passwords remain valid. + # @param [] sessions Whether a sign-in with a breached password is refused until the password is reset. Default is false, which allows the sign-in and only records the result. + # @param [] users Whether a breached password is rejected when a user signs up or sets a new password. Default is false, which allows the password and only records the result. + # + # @return [Project] + def update_password_pwned_policy( + enabled: nil, + sessions: nil, + users: nil + ) + api_path = '/project/policies/password-pwned' + + api_params = { + enabled: enabled, + sessions: sessions, + users: users, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Project + ) + end + + # Require a password reset when an email/password sign-in uses a password + # older than the configured maximum age. Options left out keep their current + # value. + # + # @param [] enabled Enable password rotation. Disabled by default. + # @param [Integer] max_age Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + # + # @return [Project] + def update_password_rotation_policy( + enabled: nil, + max_age: nil + ) + api_path = '/project/policies/password-rotation' + + api_params = { + enabled: enabled, + maxAge: max_age, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Project + ) + end + # Update the password strength requirements for users in the project. # # @param [Integer] min Minimum password length. Value must be between 8 and 256. Default is 8. @@ -3757,7 +4171,7 @@ def update_user_limit_policy( # # @param [ProjectPolicyId] policy_id Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. # - # @return [PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordStrength, PolicyPasswordPersonalData, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy, PolicyMfaFactors, PolicyDenyAliasedEmail, PolicyDenyDisposableEmail, PolicyDenyFreeEmail, PolicyDenyCorporateEmail, PolicyPasskey] + # @return [PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordStrength, PolicyPasswordPersonalData, PolicyPasswordPwned, PolicyPasswordRotation, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy, PolicyMfaFactors, PolicyDenyAliasedEmail, PolicyDenyDisposableEmail, PolicyDenyFreeEmail, PolicyDenyCorporateEmail, PolicyPasskey] def get_policy( policy_id: ) @@ -3806,6 +4220,16 @@ def get_policy( return Models::PolicyPasswordPersonalData.from(map: response) end + if response['$id'] == 'password-pwned' + + return Models::PolicyPasswordPwned.from(map: response) + end + + if response['$id'] == 'password-rotation' + + return Models::PolicyPasswordRotation.from(map: response) + end + if response['$id'] == 'session-alert' return Models::PolicySessionAlert.from(map: response) diff --git a/lib/appwrite/services/sites.rb b/lib/appwrite/services/sites.rb index 8c191805..46a830f2 100644 --- a/lib/appwrite/services/sites.rb +++ b/lib/appwrite/services/sites.rb @@ -158,12 +158,17 @@ def create( # Get a list of all frameworks that are currently available on the server # instance. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [FrameworkList] - def list_frameworks() + def list_frameworks( + total: nil + ) api_path = '/sites/frameworks' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -182,15 +187,18 @@ def list_frameworks() # List allowed site specifications for this instance. # # @param [String] type Specification type to list. Can be one of: runtimes, builds. Defaults to runtimes. + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [SpecificationList] def list_specifications( - type: nil + type: nil, + total: nil ) api_path = '/sites/specifications' api_params = { type: type, + total: total, } api_headers = { diff --git a/lib/appwrite/services/tables_db.rb b/lib/appwrite/services/tables_db.rb index c1ee72b5..ef709de8 100644 --- a/lib/appwrite/services/tables_db.rb +++ b/lib/appwrite/services/tables_db.rb @@ -122,15 +122,18 @@ def list_specifications() # List transactions across all databases. # # @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). + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [TransactionList] def list_transactions( - queries: nil + queries: nil, + total: nil ) api_path = '/tablesdb/transactions' api_params = { queries: queries, + total: total, } api_headers = { diff --git a/lib/appwrite/services/teams.rb b/lib/appwrite/services/teams.rb index d6325633..8e19b572 100644 --- a/lib/appwrite/services/teams.rb +++ b/lib/appwrite/services/teams.rb @@ -469,6 +469,7 @@ def list_memberships( # @param [String] phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. # @param [String] url URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project 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] name Name of the new team member. Max length: 128 chars. + # @param [String] membership_id Membership 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. # # @return [Membership] def create_membership( @@ -478,7 +479,8 @@ def create_membership( user_id: nil, phone: nil, url: nil, - name: nil + name: nil, + membership_id: nil ) api_path = '/teams/{teamId}/memberships' .gsub('{teamId}', team_id) @@ -498,6 +500,7 @@ def create_membership( roles: roles, url: url, name: name, + membershipId: membership_id, } api_headers = { diff --git a/lib/appwrite/services/vectors_db.rb b/lib/appwrite/services/vectors_db.rb index c0b1fa6e..5d8fe64e 100644 --- a/lib/appwrite/services/vectors_db.rb +++ b/lib/appwrite/services/vectors_db.rb @@ -119,15 +119,18 @@ def list_specifications() # List transactions across all databases. # # @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). + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [TransactionList] def list_transactions( - queries: nil + queries: nil, + total: nil ) api_path = '/vectorsdb/transactions' api_params = { queries: queries, + total: total, } api_headers = { diff --git a/lib/appwrite/services/waf.rb b/lib/appwrite/services/waf.rb new file mode 100644 index 00000000..949dd1ee --- /dev/null +++ b/lib/appwrite/services/waf.rb @@ -0,0 +1,859 @@ +# frozen_string_literal: true + +module Appwrite + class Waf < Service + def initialize(client) + @client = client + end + + # List WAF rules for 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. + # @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. + # + # @return [WafRuleList] + def list_rules( + queries: nil, + search: nil, + total: nil + ) + api_path = '/waf/rules' + + api_params = { + queries: queries, + search: search, + total: total, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleList + ) + end + + # Create a bypass WAF rule. Conditions can match request attributes including + # `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, + # `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, + # `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + # `browserVersion`. Conditions on `city` and `state` require the premium Geo + # DB addon. + # + # + # @param [String] rule_id Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] name Rule name. + # @param [String] resource_id Resource identifier. Leave empty for the API resource type. + # @param [String] description Optional description for the rule. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to create the rule in a disabled state. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleBypass] + def create_bypass_rule( + rule_id:, + resource_type:, + name:, + resource_id: nil, + description: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + if resource_type.nil? + raise Appwrite::Exception.new('Missing required parameter: "resourceType"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + api_path = '/waf/rules/bypass' + + api_params = { + ruleId: rule_id, + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleBypass + ) + end + + # Update a bypass WAF rule. Conditions can match request attributes including + # `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, + # `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, + # `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + # `browserVersion`. Conditions on `city` and `state` require the premium Geo + # DB addon. + # + # + # @param [String] rule_id Rule ID. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] name Rule name. + # @param [String] description Optional description for the rule. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to disable the rule. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleBypass] + def update_bypass_rule( + rule_id:, + resource_type: nil, + resource_id: nil, + name: nil, + description: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + api_path = '/waf/rules/bypass/{ruleId}' + .gsub('{ruleId}', rule_id) + + api_params = { + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleBypass + ) + end + + # Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to + # tune the client-side proof-of-work cost, and `ttl` to control how long, in + # seconds, a visitor stays cleared after passing the challenge before being + # challenged again. Conditions can match request attributes including `ip` + # (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, + # `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, + # `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions + # on `city` and `state` require the premium Geo DB addon. + # + # + # @param [String] rule_id Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] name Rule name. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] description Optional description for the rule. + # @param [String] challenge_type Challenge type enforced by the rule. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to create the rule in a disabled state. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # @param [Integer] difficulty Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + # @param [Integer] ttl How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + # + # @return [WafRuleChallenge] + def create_challenge_rule( + rule_id:, + resource_type:, + name:, + resource_id: nil, + description: nil, + challenge_type: nil, + priority: nil, + enabled: nil, + conditions: nil, + difficulty: nil, + ttl: nil + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + if resource_type.nil? + raise Appwrite::Exception.new('Missing required parameter: "resourceType"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + api_path = '/waf/rules/challenge' + + api_params = { + ruleId: rule_id, + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + challengeType: challenge_type, + priority: priority, + enabled: enabled, + conditions: conditions, + difficulty: difficulty, + ttl: ttl, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleChallenge + ) + end + + # Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to + # tune the client-side proof-of-work cost, and `ttl` to control how long, in + # seconds, a visitor stays cleared after passing the challenge before being + # challenged again. Conditions can match request attributes including `ip` + # (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, + # `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, + # `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions + # on `city` and `state` require the premium Geo DB addon. + # + # + # @param [String] rule_id Rule ID. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] name Rule name. + # @param [String] description Optional description for the rule. + # @param [String] challenge_type Challenge type enforced by the rule. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to disable the rule. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # @param [Integer] difficulty Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + # @param [Integer] ttl How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + # + # @return [WafRuleChallenge] + def update_challenge_rule( + rule_id:, + resource_type: nil, + resource_id: nil, + name: nil, + description: nil, + challenge_type: nil, + priority: nil, + enabled: nil, + conditions: nil, + difficulty: nil, + ttl: nil + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + api_path = '/waf/rules/challenge/{ruleId}' + .gsub('{ruleId}', rule_id) + + api_params = { + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + challengeType: challenge_type, + priority: priority, + enabled: enabled, + conditions: conditions, + difficulty: difficulty, + ttl: ttl, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleChallenge + ) + end + + # Create a deny WAF rule. Conditions can match request attributes including + # `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, + # `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, + # `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + # `browserVersion`. Conditions on `city` and `state` require the premium Geo + # DB addon. + # + # + # @param [String] rule_id Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] name Rule name. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] description Optional description for the rule. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to create the rule in a disabled state. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleDeny] + def create_deny_rule( + rule_id:, + resource_type:, + name:, + resource_id: nil, + description: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + if resource_type.nil? + raise Appwrite::Exception.new('Missing required parameter: "resourceType"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + api_path = '/waf/rules/deny' + + api_params = { + ruleId: rule_id, + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleDeny + ) + end + + # Update a deny WAF rule. Conditions can match request attributes including + # `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, + # `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, + # `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + # `browserVersion`. Conditions on `city` and `state` require the premium Geo + # DB addon. + # + # + # @param [String] rule_id Rule ID. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] name Rule name. + # @param [String] description Optional description for the rule. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to disable the rule. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleDeny] + def update_deny_rule( + rule_id:, + resource_type: nil, + resource_id: nil, + name: nil, + description: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + api_path = '/waf/rules/deny/{ruleId}' + .gsub('{ruleId}', rule_id) + + api_params = { + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleDeny + ) + end + + # Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits + # per client IP, while `userId` limits per authenticated user (requests + # without an authenticated user skip `userId` rules). Conditions can match + # request attributes including `ip` (plain IPs or CIDR blocks like + # `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, + # `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, + # `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and + # `state` require the premium Geo DB addon. + # + # + # @param [String] rule_id Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] name Rule name. + # @param [Integer] limit Maximum number of matching requests allowed in the configured interval. + # @param [Integer] interval Interval in seconds used for rate limiting. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] description Optional description for the rule. + # @param [String] key Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + # @param [String] strategy Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + # @param [Integer] max_bucket_size Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to create the rule in a disabled state. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleRateLimit] + def create_rate_limit_rule( + rule_id:, + resource_type:, + name:, + limit:, + interval:, + resource_id: nil, + description: nil, + key: nil, + strategy: nil, + max_bucket_size: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + if resource_type.nil? + raise Appwrite::Exception.new('Missing required parameter: "resourceType"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if limit.nil? + raise Appwrite::Exception.new('Missing required parameter: "limit"') + end + + if interval.nil? + raise Appwrite::Exception.new('Missing required parameter: "interval"') + end + + api_path = '/waf/rules/rate-limit' + + api_params = { + ruleId: rule_id, + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + limit: limit, + interval: interval, + key: key, + strategy: strategy, + maxBucketSize: max_bucket_size, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleRateLimit + ) + end + + # Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits + # per client IP, while `userId` limits per authenticated user (requests + # without an authenticated user skip `userId` rules). Conditions can match + # request attributes including `ip` (plain IPs or CIDR blocks like + # `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, + # `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, + # `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and + # `state` require the premium Geo DB addon. + # + # + # @param [String] rule_id Rule ID. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] name Rule name. + # @param [String] description Optional description for the rule. + # @param [Integer] limit Maximum number of matching requests allowed in the configured interval. + # @param [Integer] interval Interval in seconds used for rate limiting. + # @param [String] key Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + # @param [Integer] max_bucket_size Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to disable the rule. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleRateLimit] + def update_rate_limit_rule( + rule_id:, + resource_type: nil, + resource_id: nil, + name: nil, + description: nil, + limit: nil, + interval: nil, + key: nil, + max_bucket_size: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + api_path = '/waf/rules/rate-limit/{ruleId}' + .gsub('{ruleId}', rule_id) + + api_params = { + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + limit: limit, + interval: interval, + key: key, + maxBucketSize: max_bucket_size, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleRateLimit + ) + end + + # Create a redirect WAF rule. Conditions can match request attributes + # including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, + # `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, + # `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + # `browserVersion`. Conditions on `city` and `state` require the premium Geo + # DB addon. + # + # + # @param [String] rule_id Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] name Rule name. + # @param [String] location Location used for redirect responses. + # @param [Integer] status_code Integer status code used for redirect responses. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] description Optional description for the rule. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to create the rule in a disabled state. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleRedirect] + def create_redirect_rule( + rule_id:, + resource_type:, + name:, + location:, + status_code:, + resource_id: nil, + description: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + if resource_type.nil? + raise Appwrite::Exception.new('Missing required parameter: "resourceType"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if location.nil? + raise Appwrite::Exception.new('Missing required parameter: "location"') + end + + if status_code.nil? + raise Appwrite::Exception.new('Missing required parameter: "statusCode"') + end + + api_path = '/waf/rules/redirect' + + api_params = { + ruleId: rule_id, + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + location: location, + statusCode: status_code, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleRedirect + ) + end + + # Update a redirect WAF rule. Conditions can match request attributes + # including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, + # `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, + # `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + # `browserVersion`. Conditions on `city` and `state` require the premium Geo + # DB addon. + # + # + # @param [String] rule_id Rule ID. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] name Rule name. + # @param [String] description Optional description for the rule. + # @param [String] location Location used for redirect responses. + # @param [Integer] status_code Integer status code used for redirect responses. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to disable the rule. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleRedirect] + def update_redirect_rule( + rule_id:, + resource_type: nil, + resource_id: nil, + name: nil, + description: nil, + location: nil, + status_code: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + api_path = '/waf/rules/redirect/{ruleId}' + .gsub('{ruleId}', rule_id) + + api_params = { + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + location: location, + statusCode: status_code, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleRedirect + ) + end + + # Get a WAF rule by its ID. + # + # + # @param [String] rule_id Rule ID. + # + # @return [WafRuleBypass, WafRuleDeny, WafRuleChallenge, WafRuleRateLimit, WafRuleRedirect] + def get_rule( + rule_id: + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + api_path = '/waf/rules/{ruleId}' + .gsub('{ruleId}', rule_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + 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['action'] == 'bypass' + + return Models::WafRuleBypass.from(map: response) + end + + if response['action'] == 'deny' + + return Models::WafRuleDeny.from(map: response) + end + + if response['action'] == 'challenge' + + return Models::WafRuleChallenge.from(map: response) + end + + if response['action'] == 'rateLimit' + + return Models::WafRuleRateLimit.from(map: response) + end + + if response['action'] == 'redirect' + + return Models::WafRuleRedirect.from(map: response) + end + + raise Exception, "Unable to match response to any expected response model" + end + + # Delete a WAF rule. + # + # + # @param [String] rule_id Rule ID. + # + # @return [] + def delete_rule( + rule_id: + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + api_path = '/waf/rules/{ruleId}' + .gsub('{ruleId}', rule_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + end + end +end