diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 31e26c48..4ab3cc7b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,10 +9,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Set up Ruby - uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0 + uses: ruby/setup-ruby@a30dfa457ad68707b8b910ac3a244714b61c0626 # v1.320.0 with: ruby-version: 2.7 bundler-cache: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 37d2172a..bdf22ea1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +## 26.1.0 + +* Added: `Apps` service for managing OAuth2 applications, keys, and installations +* Added: `OAuth2` service with authorize, grant, device authorization, and consent flows +* Added: account OAuth2 consent methods `list_consents`, `get_consent`, `delete_consent`, and consent token methods +* Added: app installation management methods to `Organization` and `Teams` services +* Added: `installation_access_token_duration` parameter to `project.update_o_auth2_server` +* Added: `token` parameter to `sites.get_deployment_download` +* Added: `oauth2.introspect` and organization installation key scopes + ## 26.0.0 * Breaking: Removed `Health` service and all health models and enums diff --git a/appwrite.gemspec b/appwrite.gemspec index 1233f9c1..bc428bcb 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '26.0.0' + spec.version = '26.1.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/delete-consent-token.md b/docs/examples/account/delete-consent-token.md new file mode 100644 index 00000000..3e3c11e5 --- /dev/null +++ b/docs/examples/account/delete-consent-token.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.delete_consent_token( + consent_id: '', + token_id: '' +) +``` diff --git a/docs/examples/account/delete-consent.md b/docs/examples/account/delete-consent.md new file mode 100644 index 00000000..b673c204 --- /dev/null +++ b/docs/examples/account/delete-consent.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.delete_consent( + consent_id: '' +) +``` diff --git a/docs/examples/account/get-consent-token.md b/docs/examples/account/get-consent-token.md new file mode 100644 index 00000000..d65e22dd --- /dev/null +++ b/docs/examples/account/get-consent-token.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.get_consent_token( + consent_id: '', + token_id: '' +) +``` diff --git a/docs/examples/account/get-consent.md b/docs/examples/account/get-consent.md new file mode 100644 index 00000000..8fe59764 --- /dev/null +++ b/docs/examples/account/get-consent.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.get_consent( + consent_id: '' +) +``` diff --git a/docs/examples/account/list-consent-tokens.md b/docs/examples/account/list-consent-tokens.md new file mode 100644 index 00000000..1d7f6049 --- /dev/null +++ b/docs/examples/account/list-consent-tokens.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.list_consent_tokens( + consent_id: '', + queries: [], # optional + total: false # optional +) +``` diff --git a/docs/examples/account/list-consents.md b/docs/examples/account/list-consents.md new file mode 100644 index 00000000..968c1e55 --- /dev/null +++ b/docs/examples/account/list-consents.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.list_consents( + queries: [], # optional + total: false # optional +) +``` diff --git a/docs/examples/apps/create-installation-token.md b/docs/examples/apps/create-installation-token.md new file mode 100644 index 00000000..7c71cecc --- /dev/null +++ b/docs/examples/apps/create-installation-token.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 + +apps = Apps.new(client) + +result = apps.create_installation_token( + app_id: '', + installation_id: '' +) +``` diff --git a/docs/examples/apps/create-key.md b/docs/examples/apps/create-key.md new file mode 100644 index 00000000..31243477 --- /dev/null +++ b/docs/examples/apps/create-key.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +apps = Apps.new(client) + +result = apps.create_key( + app_id: '' +) +``` diff --git a/docs/examples/apps/create-secret.md b/docs/examples/apps/create-secret.md new file mode 100644 index 00000000..7b26ea6a --- /dev/null +++ b/docs/examples/apps/create-secret.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 + +apps = Apps.new(client) + +result = apps.create_secret( + app_id: '' +) +``` diff --git a/docs/examples/apps/create.md b/docs/examples/apps/create.md new file mode 100644 index 00000000..94da7f01 --- /dev/null +++ b/docs/examples/apps/create.md @@ -0,0 +1,34 @@ +```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 + +apps = Apps.new(client) + +result = apps.create( + app_id: '', + name: '', + redirect_uris: [], + description: '', # optional + client_uri: 'https://example.com', # optional + logo_uri: 'https://example.com', # optional + privacy_policy_url: 'https://example.com', # optional + terms_url: 'https://example.com', # optional + contacts: [], # optional + tagline: '', # optional + tags: [], # optional + images: [], # optional + support_url: 'https://example.com', # optional + data_deletion_url: 'https://example.com', # optional + post_logout_redirect_uris: [], # optional + enabled: false, # optional + type: 'public', # optional + device_flow: false, # optional + team_id: '' # optional +) +``` diff --git a/docs/examples/apps/delete-key.md b/docs/examples/apps/delete-key.md new file mode 100644 index 00000000..70ea81fa --- /dev/null +++ b/docs/examples/apps/delete-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_session('') # The user session to authenticate with + +apps = Apps.new(client) + +result = apps.delete_key( + app_id: '', + key_id: '' +) +``` diff --git a/docs/examples/apps/delete-secret.md b/docs/examples/apps/delete-secret.md new file mode 100644 index 00000000..a0335204 --- /dev/null +++ b/docs/examples/apps/delete-secret.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 + +apps = Apps.new(client) + +result = apps.delete_secret( + app_id: '', + secret_id: '' +) +``` diff --git a/docs/examples/apps/delete-tokens.md b/docs/examples/apps/delete-tokens.md new file mode 100644 index 00000000..e15cf22b --- /dev/null +++ b/docs/examples/apps/delete-tokens.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 + +apps = Apps.new(client) + +result = apps.delete_tokens( + app_id: '' +) +``` diff --git a/docs/examples/apps/delete.md b/docs/examples/apps/delete.md new file mode 100644 index 00000000..614c5027 --- /dev/null +++ b/docs/examples/apps/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_session('') # The user session to authenticate with + +apps = Apps.new(client) + +result = apps.delete( + app_id: '' +) +``` diff --git a/docs/examples/apps/get-installation.md b/docs/examples/apps/get-installation.md new file mode 100644 index 00000000..5db2961b --- /dev/null +++ b/docs/examples/apps/get-installation.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 + +apps = Apps.new(client) + +result = apps.get_installation( + app_id: '', + installation_id: '' +) +``` diff --git a/docs/examples/apps/get-key.md b/docs/examples/apps/get-key.md new file mode 100644 index 00000000..b6b1c2af --- /dev/null +++ b/docs/examples/apps/get-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_session('') # The user session to authenticate with + +apps = Apps.new(client) + +result = apps.get_key( + app_id: '', + key_id: '' +) +``` diff --git a/docs/examples/apps/get-secret.md b/docs/examples/apps/get-secret.md new file mode 100644 index 00000000..57adff38 --- /dev/null +++ b/docs/examples/apps/get-secret.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 + +apps = Apps.new(client) + +result = apps.get_secret( + app_id: '', + secret_id: '' +) +``` diff --git a/docs/examples/apps/get.md b/docs/examples/apps/get.md new file mode 100644 index 00000000..9f06a501 --- /dev/null +++ b/docs/examples/apps/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_session('') # The user session to authenticate with + +apps = Apps.new(client) + +result = apps.get( + app_id: '' +) +``` diff --git a/docs/examples/apps/list-installation-scopes.md b/docs/examples/apps/list-installation-scopes.md new file mode 100644 index 00000000..eef52129 --- /dev/null +++ b/docs/examples/apps/list-installation-scopes.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 + +apps = Apps.new(client) + +result = apps.list_installation_scopes() +``` diff --git a/docs/examples/apps/list-installations.md b/docs/examples/apps/list-installations.md new file mode 100644 index 00000000..da01dc8e --- /dev/null +++ b/docs/examples/apps/list-installations.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 + +apps = Apps.new(client) + +result = apps.list_installations( + app_id: '', + queries: [], # optional + total: false # optional +) +``` diff --git a/docs/examples/apps/list-keys.md b/docs/examples/apps/list-keys.md new file mode 100644 index 00000000..9a7e19ec --- /dev/null +++ b/docs/examples/apps/list-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_session('') # The user session to authenticate with + +apps = Apps.new(client) + +result = apps.list_keys( + app_id: '', + queries: [], # optional + total: false # optional +) +``` diff --git a/docs/examples/apps/list-o-auth-2-scopes.md b/docs/examples/apps/list-o-auth-2-scopes.md new file mode 100644 index 00000000..92cbb804 --- /dev/null +++ b/docs/examples/apps/list-o-auth-2-scopes.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 + +apps = Apps.new(client) + +result = apps.list_o_auth2_scopes() +``` diff --git a/docs/examples/apps/list-secrets.md b/docs/examples/apps/list-secrets.md new file mode 100644 index 00000000..f7728903 --- /dev/null +++ b/docs/examples/apps/list-secrets.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 + +apps = Apps.new(client) + +result = apps.list_secrets( + app_id: '', + queries: [], # optional + total: false # optional +) +``` diff --git a/docs/examples/apps/list.md b/docs/examples/apps/list.md new file mode 100644 index 00000000..75ab272e --- /dev/null +++ b/docs/examples/apps/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_session('') # The user session to authenticate with + +apps = Apps.new(client) + +result = apps.list( + queries: [], # optional + total: false # optional +) +``` diff --git a/docs/examples/apps/update-labels.md b/docs/examples/apps/update-labels.md new file mode 100644 index 00000000..1705f8bf --- /dev/null +++ b/docs/examples/apps/update-labels.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 + +apps = Apps.new(client) + +result = apps.update_labels( + app_id: '', + labels: [] +) +``` diff --git a/docs/examples/apps/update-team.md b/docs/examples/apps/update-team.md new file mode 100644 index 00000000..a47a58e5 --- /dev/null +++ b/docs/examples/apps/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_session('') # The user session to authenticate with + +apps = Apps.new(client) + +result = apps.update_team( + app_id: '', + team_id: '' +) +``` diff --git a/docs/examples/apps/update.md b/docs/examples/apps/update.md new file mode 100644 index 00000000..f8fd0a32 --- /dev/null +++ b/docs/examples/apps/update.md @@ -0,0 +1,35 @@ +```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 + +apps = Apps.new(client) + +result = apps.update( + app_id: '', + name: '', + description: '', # optional + client_uri: 'https://example.com', # optional + logo_uri: 'https://example.com', # optional + privacy_policy_url: 'https://example.com', # optional + terms_url: 'https://example.com', # optional + contacts: [], # optional + tagline: '', # optional + tags: [], # optional + images: [], # optional + support_url: 'https://example.com', # optional + data_deletion_url: 'https://example.com', # optional + enabled: false, # optional + redirect_uris: [], # optional + post_logout_redirect_uris: [], # optional + type: 'public', # optional + device_flow: false, # optional + installation_scopes: [], # optional + installation_redirect_url: 'https://example.com' # optional +) +``` diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md index 831c2aa1..f6509087 100644 --- a/docs/examples/backups/create-restoration.md +++ b/docs/examples/backups/create-restoration.md @@ -15,7 +15,6 @@ result = backups.create_restoration( archive_id: '', services: [BackupServices::DATABASES], new_resource_id: '', # optional - new_resource_name: '', # optional - new_specification: 'serverless' # optional + new_resource_name: '' # optional ) ``` diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md new file mode 100644 index 00000000..6576dbec --- /dev/null +++ b/docs/examples/oauth2/approve.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_session('') # The user session to authenticate with + .set_project('') # Your project ID + +oauth2 = Oauth2.new(client) + +result = oauth2.approve( + grant_id: '', + authorization_details: '', # optional + scope: '' # optional +) +``` diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md new file mode 100644 index 00000000..75f092a2 --- /dev/null +++ b/docs/examples/oauth2/authorize-post.md @@ -0,0 +1,29 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_session('') # The user session to authenticate with + .set_project('') # Your project ID + +oauth2 = Oauth2.new(client) + +result = oauth2.authorize_post( + client_id: '', # optional + redirect_uri: 'https://example.com', # optional + response_type: '', # optional + scope: '', # optional + state: '', # optional + nonce: '', # optional + code_challenge: '', # optional + code_challenge_method: 's256', # optional + prompt: '', # optional + max_age: 0, # optional + authorization_details: '', # optional + resource: '', # optional + audience: '', # optional + request_uri: '' # optional +) +``` diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md new file mode 100644 index 00000000..d7d5befc --- /dev/null +++ b/docs/examples/oauth2/authorize.md @@ -0,0 +1,29 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_session('') # The user session to authenticate with + .set_project('') # Your project ID + +oauth2 = Oauth2.new(client) + +result = oauth2.authorize( + client_id: '', # optional + redirect_uri: 'https://example.com', # optional + response_type: '', # optional + scope: '', # optional + state: '', # optional + nonce: '', # optional + code_challenge: '', # optional + code_challenge_method: 's256', # optional + prompt: '', # optional + max_age: 0, # optional + authorization_details: '', # optional + resource: '', # optional + audience: '', # optional + request_uri: '' # optional +) +``` diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md new file mode 100644 index 00000000..102671db --- /dev/null +++ b/docs/examples/oauth2/create-device-authorization.md @@ -0,0 +1,20 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_session('') # The user session to authenticate with + .set_project('') # Your project ID + +oauth2 = Oauth2.new(client) + +result = oauth2.create_device_authorization( + client_id: '', # optional + scope: '', # optional + authorization_details: '', # optional + resource: '', # optional + audience: '' # optional +) +``` diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md new file mode 100644 index 00000000..9184cbf7 --- /dev/null +++ b/docs/examples/oauth2/create-grant.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_session('') # The user session to authenticate with + .set_project('') # Your project ID + +oauth2 = Oauth2.new(client) + +result = oauth2.create_grant( + user_code: '' +) +``` diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md new file mode 100644 index 00000000..192e5ff1 --- /dev/null +++ b/docs/examples/oauth2/create-par.md @@ -0,0 +1,28 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_session('') # The user session to authenticate with + .set_project('') # Your project ID + +oauth2 = Oauth2.new(client) + +result = oauth2.create_par( + client_id: '', + redirect_uri: 'https://example.com', + response_type: 'code', + scope: '', # optional + state: '', # optional + nonce: '', # optional + code_challenge: '', # optional + code_challenge_method: 's256', # optional + prompt: '', # optional + max_age: 0, # optional + authorization_details: '', # optional + resource: '', # optional + audience: '' # optional +) +``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md new file mode 100644 index 00000000..6e0cabc1 --- /dev/null +++ b/docs/examples/oauth2/create-token.md @@ -0,0 +1,25 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_session('') # The user session to authenticate with + .set_project('') # Your project ID + +oauth2 = Oauth2.new(client) + +result = oauth2.create_token( + grant_type: '', + code: '', # optional + refresh_token: '', # optional + device_code: '', # optional + client_id: '', # optional + client_secret: '', # optional + code_verifier: '', # optional + redirect_uri: 'https://example.com', # optional + resource: '', # optional + audience: '' # optional +) +``` diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md new file mode 100644 index 00000000..e6b80763 --- /dev/null +++ b/docs/examples/oauth2/get-grant.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_session('') # The user session to authenticate with + .set_project('') # Your project ID + +oauth2 = Oauth2.new(client) + +result = oauth2.get_grant( + grant_id: '' +) +``` diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md new file mode 100644 index 00000000..28b026e4 --- /dev/null +++ b/docs/examples/oauth2/list-organizations.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_session('') # The user session to authenticate with + .set_project('') # Your project ID + +oauth2 = Oauth2.new(client) + +result = oauth2.list_organizations( + limit: 1, # optional + offset: 0, # optional + search: '' # optional +) +``` diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md new file mode 100644 index 00000000..3f8c64f2 --- /dev/null +++ b/docs/examples/oauth2/list-projects.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_session('') # The user session to authenticate with + .set_project('') # Your project ID + +oauth2 = Oauth2.new(client) + +result = oauth2.list_projects( + limit: 1, # optional + offset: 0, # optional + search: '' # optional +) +``` diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md new file mode 100644 index 00000000..bf00d990 --- /dev/null +++ b/docs/examples/oauth2/reject.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_session('') # The user session to authenticate with + .set_project('') # Your project ID + +oauth2 = Oauth2.new(client) + +result = oauth2.reject( + grant_id: '' +) +``` diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md new file mode 100644 index 00000000..6b709451 --- /dev/null +++ b/docs/examples/oauth2/revoke.md @@ -0,0 +1,19 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_session('') # The user session to authenticate with + .set_project('') # Your project ID + +oauth2 = Oauth2.new(client) + +result = oauth2.revoke( + token: '', + token_type_hint: 'access_token', # optional + client_id: '', # optional + client_secret: '' # optional +) +``` diff --git a/docs/examples/organization/create-installation.md b/docs/examples/organization/create-installation.md new file mode 100644 index 00000000..a36a41e0 --- /dev/null +++ b/docs/examples/organization/create-installation.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 + +organization = Organization.new(client) + +result = organization.create_installation( + app_id: '', + authorization_details: '' # optional +) +``` diff --git a/docs/examples/organization/delete-installation.md b/docs/examples/organization/delete-installation.md new file mode 100644 index 00000000..c906fc18 --- /dev/null +++ b/docs/examples/organization/delete-installation.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 + +organization = Organization.new(client) + +result = organization.delete_installation( + installation_id: '' +) +``` diff --git a/docs/examples/organization/get-installation.md b/docs/examples/organization/get-installation.md new file mode 100644 index 00000000..32c08766 --- /dev/null +++ b/docs/examples/organization/get-installation.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 + +organization = Organization.new(client) + +result = organization.get_installation( + installation_id: '' +) +``` diff --git a/docs/examples/organization/list-installations.md b/docs/examples/organization/list-installations.md new file mode 100644 index 00000000..92214d26 --- /dev/null +++ b/docs/examples/organization/list-installations.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 + +organization = Organization.new(client) + +result = organization.list_installations( + queries: [], # optional + total: false # optional +) +``` diff --git a/docs/examples/organization/update-installation.md b/docs/examples/organization/update-installation.md new file mode 100644 index 00000000..db7c932e --- /dev/null +++ b/docs/examples/organization/update-installation.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 + +organization = Organization.new(client) + +result = organization.update_installation( + installation_id: '', + authorization_details: '' # optional +) +``` diff --git a/docs/examples/project/update-o-auth-2-server.md b/docs/examples/project/update-o-auth-2-server.md index b3ab3399..92a56d27 100644 --- a/docs/examples/project/update-o-auth-2-server.md +++ b/docs/examples/project/update-o-auth-2-server.md @@ -19,6 +19,7 @@ result = project.update_o_auth2_server( refresh_token_duration: 60, # optional public_access_token_duration: 60, # optional public_refresh_token_duration: 60, # optional + installation_access_token_duration: 60, # optional confidential_pkce: false, # optional verification_url: 'https://example.com', # optional user_code_length: 6, # optional diff --git a/docs/examples/sites/get-deployment-download.md b/docs/examples/sites/get-deployment-download.md index 0fe19a3c..55206b43 100644 --- a/docs/examples/sites/get-deployment-download.md +++ b/docs/examples/sites/get-deployment-download.md @@ -14,6 +14,7 @@ sites = Sites.new(client) result = sites.get_deployment_download( site_id: '', deployment_id: '', - type: DeploymentDownloadType::SOURCE # optional + type: DeploymentDownloadType::SOURCE, # optional + token: '' # optional ) ``` diff --git a/docs/examples/tablesdb/create-failover.md b/docs/examples/tablesdb/create-failover.md new file mode 100644 index 00000000..4935f32d --- /dev/null +++ b/docs/examples/tablesdb/create-failover.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +tables_db = TablesDB.new(client) + +result = tables_db.create_failover( + database_id: '', + target_replica_id: '' # optional +) +``` diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md index 10ab1a45..433b5b72 100644 --- a/docs/examples/tablesdb/create.md +++ b/docs/examples/tablesdb/create.md @@ -14,6 +14,7 @@ result = tables_db.create( database_id: '', name: '', enabled: false, # optional - specification: 'serverless' # optional + specification: 'serverless', # optional + replicas: 0 # optional ) ``` diff --git a/docs/examples/tablesdb/get-replicas.md b/docs/examples/tablesdb/get-replicas.md new file mode 100644 index 00000000..a8fb122c --- /dev/null +++ b/docs/examples/tablesdb/get-replicas.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +tables_db = TablesDB.new(client) + +result = tables_db.get_replicas( + database_id: '' +) +``` diff --git a/docs/examples/tablesdb/get-status.md b/docs/examples/tablesdb/get-status.md new file mode 100644 index 00000000..c0b68e56 --- /dev/null +++ b/docs/examples/tablesdb/get-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 + +tables_db = TablesDB.new(client) + +result = tables_db.get_status( + database_id: '' +) +``` diff --git a/docs/examples/tablesdb/list-specifications.md b/docs/examples/tablesdb/list-specifications.md new file mode 100644 index 00000000..8aa6987b --- /dev/null +++ b/docs/examples/tablesdb/list-specifications.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_key('') # Your secret API key + +tables_db = TablesDB.new(client) + +result = tables_db.list_specifications() +``` diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md index 28377a61..4257090a 100644 --- a/docs/examples/tablesdb/update.md +++ b/docs/examples/tablesdb/update.md @@ -13,6 +13,7 @@ tables_db = TablesDB.new(client) result = tables_db.update( database_id: '', name: '', # optional - enabled: false # optional + enabled: false, # optional + replicas: 0 # optional ) ``` diff --git a/docs/examples/teams/create-installation.md b/docs/examples/teams/create-installation.md new file mode 100644 index 00000000..326c84cc --- /dev/null +++ b/docs/examples/teams/create-installation.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 + +teams = Teams.new(client) + +result = teams.create_installation( + team_id: '', + app_id: '', + authorization_details: '' # optional +) +``` diff --git a/docs/examples/teams/delete-installation.md b/docs/examples/teams/delete-installation.md new file mode 100644 index 00000000..420b289d --- /dev/null +++ b/docs/examples/teams/delete-installation.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 + +teams = Teams.new(client) + +result = teams.delete_installation( + team_id: '', + installation_id: '' +) +``` diff --git a/docs/examples/teams/get-installation.md b/docs/examples/teams/get-installation.md new file mode 100644 index 00000000..f1200564 --- /dev/null +++ b/docs/examples/teams/get-installation.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 + +teams = Teams.new(client) + +result = teams.get_installation( + team_id: '', + installation_id: '' +) +``` diff --git a/docs/examples/teams/list-installations.md b/docs/examples/teams/list-installations.md new file mode 100644 index 00000000..cfd7ea61 --- /dev/null +++ b/docs/examples/teams/list-installations.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 + +teams = Teams.new(client) + +result = teams.list_installations( + team_id: '', + queries: [], # optional + total: false # optional +) +``` diff --git a/docs/examples/teams/update-installation.md b/docs/examples/teams/update-installation.md new file mode 100644 index 00000000..66609320 --- /dev/null +++ b/docs/examples/teams/update-installation.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 + +teams = Teams.new(client) + +result = teams.update_installation( + team_id: '', + installation_id: '', + authorization_details: '' # optional +) +``` diff --git a/lib/appwrite.rb b/lib/appwrite.rb index 2b14b4a3..03d3826f 100644 --- a/lib/appwrite.rb +++ b/lib/appwrite.rb @@ -234,6 +234,10 @@ require_relative 'appwrite/models/billing_plan_dedicated_database_limits' require_relative 'appwrite/models/billing_plan_supported_addons' require_relative 'appwrite/models/block' +require_relative 'appwrite/models/dedicated_database' +require_relative 'appwrite/models/database_status' +require_relative 'appwrite/models/dedicated_database_member' +require_relative 'appwrite/models/dedicated_database_replicas' require_relative 'appwrite/models/organization' require_relative 'appwrite/models/backup_policy' require_relative 'appwrite/models/policy_deny_aliased_email' @@ -242,11 +246,43 @@ require_relative 'appwrite/models/policy_deny_corporate_email' require_relative 'appwrite/models/program' require_relative 'appwrite/models/backup_restoration' +require_relative 'appwrite/models/dedicated_database_specification' +require_relative 'appwrite/models/dedicated_database_specification_list' +require_relative 'appwrite/models/dedicated_database_specification_pricing' +require_relative 'appwrite/models/database_status_connections' +require_relative 'appwrite/models/database_status_replica' +require_relative 'appwrite/models/database_status_volume' require_relative 'appwrite/models/usage_billing_plan' +require_relative 'appwrite/models/app' +require_relative 'appwrite/models/app_secret' +require_relative 'appwrite/models/app_secret_plaintext' +require_relative 'appwrite/models/app_scope' +require_relative 'appwrite/models/app_installation' +require_relative 'appwrite/models/app_key' +require_relative 'appwrite/models/oauth2_authorize' +require_relative 'appwrite/models/oauth2_approve' +require_relative 'appwrite/models/oauth2_reject' +require_relative 'appwrite/models/oauth2_grant' +require_relative 'appwrite/models/oauth2_device_authorization' +require_relative 'appwrite/models/oauth2_par' +require_relative 'appwrite/models/oauth2_token' +require_relative 'appwrite/models/oauth2_consent' +require_relative 'appwrite/models/oauth2_consent_token' +require_relative 'appwrite/models/oauth2_project' +require_relative 'appwrite/models/oauth2_organization' +require_relative 'appwrite/models/oauth2_project_list' +require_relative 'appwrite/models/oauth2_organization_list' +require_relative 'appwrite/models/oauth2_consent_list' +require_relative 'appwrite/models/oauth2_consent_token_list' require_relative 'appwrite/models/activity_event_list' require_relative 'appwrite/models/backup_archive_list' require_relative 'appwrite/models/backup_policy_list' require_relative 'appwrite/models/backup_restoration_list' +require_relative 'appwrite/models/apps_list' +require_relative 'appwrite/models/app_secret_list' +require_relative 'appwrite/models/app_scope_list' +require_relative 'appwrite/models/app_installation_list' +require_relative 'appwrite/models/app_key_list' require_relative 'appwrite/enums/authenticator_type' require_relative 'appwrite/enums/authentication_factor' @@ -311,6 +347,7 @@ require_relative 'appwrite/services/account' require_relative 'appwrite/services/activities' +require_relative 'appwrite/services/apps' require_relative 'appwrite/services/avatars' require_relative 'appwrite/services/backups' require_relative 'appwrite/services/databases' @@ -318,6 +355,7 @@ require_relative 'appwrite/services/graphql' require_relative 'appwrite/services/locale' require_relative 'appwrite/services/messaging' +require_relative 'appwrite/services/oauth2' require_relative 'appwrite/services/organization' require_relative 'appwrite/services/presences' require_relative 'appwrite/services/project' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index 94eb7fb0..aeae118a 100644 --- a/lib/appwrite/client.rb +++ b/lib/appwrite/client.rb @@ -15,7 +15,7 @@ def initialize 'x-sdk-name'=> 'Ruby', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'ruby', - 'x-sdk-version'=> '26.0.0', + 'x-sdk-version'=> '26.1.0', 'X-Appwrite-Response-Format' => '1.9.5' } @endpoint = 'https://cloud.appwrite.io/v1' diff --git a/lib/appwrite/enums/database_status.rb b/lib/appwrite/enums/database_status.rb index e0e488b2..a35fbbc6 100644 --- a/lib/appwrite/enums/database_status.rb +++ b/lib/appwrite/enums/database_status.rb @@ -3,7 +3,18 @@ module Enums module DatabaseStatus PROVISIONING = 'provisioning' READY = 'ready' + INACTIVE = 'inactive' + PAUSED = 'paused' FAILED = 'failed' + DELETING = 'deleting' + DELETED = 'deleted' + RESTORING = 'restoring' + SCALING = 'scaling' + UPGRADING = 'upgrading' + MIGRATING = 'migrating' + PAUSING = 'pausing' + RESUMING = 'resuming' + FAILING_OVER = 'failing-over' end end end \ No newline at end of file diff --git a/lib/appwrite/enums/database_type.rb b/lib/appwrite/enums/database_type.rb index 1fd3996c..1803082a 100644 --- a/lib/appwrite/enums/database_type.rb +++ b/lib/appwrite/enums/database_type.rb @@ -5,6 +5,9 @@ module DatabaseType TABLESDB = 'tablesdb' DOCUMENTSDB = 'documentsdb' VECTORSDB = 'vectorsdb' + MYSQL = 'mysql' + POSTGRESQL = 'postgresql' + MONGODB = 'mongodb' end end end \ No newline at end of file diff --git a/lib/appwrite/enums/organization_key_scopes.rb b/lib/appwrite/enums/organization_key_scopes.rb index 0263ef82..92b7da23 100644 --- a/lib/appwrite/enums/organization_key_scopes.rb +++ b/lib/appwrite/enums/organization_key_scopes.rb @@ -7,6 +7,8 @@ module OrganizationKeyScopes DEVKEYS_WRITE = 'devKeys.write' ORGANIZATION_KEYS_READ = 'organization.keys.read' ORGANIZATION_KEYS_WRITE = 'organization.keys.write' + ORGANIZATION_INSTALLATIONS_READ = 'organization.installations.read' + ORGANIZATION_INSTALLATIONS_WRITE = 'organization.installations.write' ORGANIZATION_MEMBERSHIPS_READ = 'organization.memberships.read' ORGANIZATION_MEMBERSHIPS_WRITE = 'organization.memberships.write' ORGANIZATION_READ = 'organization.read' diff --git a/lib/appwrite/enums/project_key_scopes.rb b/lib/appwrite/enums/project_key_scopes.rb index ba1b7ee1..a7ed8076 100644 --- a/lib/appwrite/enums/project_key_scopes.rb +++ b/lib/appwrite/enums/project_key_scopes.rb @@ -96,11 +96,14 @@ module ProjectKeyScopes DEDICATEDDATABASES_EXECUTE = 'dedicatedDatabases.execute' DOMAINS_READ = 'domains.read' DOMAINS_WRITE = 'domains.write' + WAFRULES_READ = 'wafRules.read' + WAFRULES_WRITE = 'wafRules.write' EVENTS_READ = 'events.read' APPS_READ = 'apps.read' APPS_WRITE = 'apps.write' OAUTH2_READ = 'oauth2.read' OAUTH2_WRITE = 'oauth2.write' + OAUTH2_INTROSPECT = 'oauth2.introspect' USAGE_READ = 'usage.read' end end diff --git a/lib/appwrite/models/activity_event.rb b/lib/appwrite/models/activity_event.rb index 0a746eef..3a000a25 100644 --- a/lib/appwrite/models/activity_event.rb +++ b/lib/appwrite/models/activity_event.rb @@ -17,10 +17,21 @@ class ActivityEvent attr_reader :ip attr_reader :mode attr_reader :country + attr_reader :continent_code + attr_reader :city + attr_reader :subdivisions + attr_reader :isp + attr_reader :autonomous_system_number + attr_reader :autonomous_system_organization + attr_reader :connection_type + attr_reader :connection_usage_type + attr_reader :connection_organization attr_reader :time attr_reader :project_id attr_reader :team_id attr_reader :hostname + attr_reader :sdk + attr_reader :sdk_version def initialize( id:, @@ -37,10 +48,21 @@ def initialize( ip:, mode:, country:, + continent_code:, + city:, + subdivisions:, + isp:, + autonomous_system_number:, + autonomous_system_organization:, + connection_type:, + connection_usage_type:, + connection_organization:, time:, project_id:, team_id:, - hostname: + hostname:, + sdk:, + sdk_version: ) @id = id @actor_type = actor_type @@ -56,10 +78,21 @@ def initialize( @ip = ip @mode = mode @country = country + @continent_code = continent_code + @city = city + @subdivisions = subdivisions + @isp = isp + @autonomous_system_number = autonomous_system_number + @autonomous_system_organization = autonomous_system_organization + @connection_type = connection_type + @connection_usage_type = connection_usage_type + @connection_organization = connection_organization @time = time @project_id = project_id @team_id = team_id @hostname = hostname + @sdk = sdk + @sdk_version = sdk_version end def self.from(map:) @@ -78,10 +111,21 @@ def self.from(map:) ip: map["ip"], mode: map["mode"], country: map["country"], + continent_code: map["continentCode"], + city: map["city"], + subdivisions: map["subdivisions"], + isp: map["isp"], + autonomous_system_number: map["autonomousSystemNumber"], + autonomous_system_organization: map["autonomousSystemOrganization"], + connection_type: map["connectionType"], + connection_usage_type: map["connectionUsageType"], + connection_organization: map["connectionOrganization"], time: map["time"], project_id: map["projectId"], team_id: map["teamId"], - hostname: map["hostname"] + hostname: map["hostname"], + sdk: map["sdk"], + sdk_version: map["sdkVersion"] ) end @@ -101,10 +145,21 @@ def to_map "ip": @ip, "mode": @mode, "country": @country, + "continentCode": @continent_code, + "city": @city, + "subdivisions": @subdivisions, + "isp": @isp, + "autonomousSystemNumber": @autonomous_system_number, + "autonomousSystemOrganization": @autonomous_system_organization, + "connectionType": @connection_type, + "connectionUsageType": @connection_usage_type, + "connectionOrganization": @connection_organization, "time": @time, "projectId": @project_id, "teamId": @team_id, - "hostname": @hostname + "hostname": @hostname, + "sdk": @sdk, + "sdkVersion": @sdk_version } end end diff --git a/lib/appwrite/models/app.rb b/lib/appwrite/models/app.rb new file mode 100644 index 00000000..e0337643 --- /dev/null +++ b/lib/appwrite/models/app.rb @@ -0,0 +1,152 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class App + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :description + attr_reader :client_uri + attr_reader :logo_uri + attr_reader :privacy_policy_url + attr_reader :terms_url + attr_reader :contacts + attr_reader :tagline + attr_reader :tags + attr_reader :labels + attr_reader :images + attr_reader :support_url + attr_reader :data_deletion_url + attr_reader :redirect_uris + attr_reader :post_logout_redirect_uris + attr_reader :enabled + attr_reader :type + attr_reader :device_flow + attr_reader :team_id + attr_reader :user_id + attr_reader :installation_scopes + attr_reader :installation_redirect_url + attr_reader :secrets + + def initialize( + id:, + created_at:, + updated_at:, + name:, + description:, + client_uri:, + logo_uri:, + privacy_policy_url:, + terms_url:, + contacts:, + tagline:, + tags:, + labels:, + images:, + support_url:, + data_deletion_url:, + redirect_uris:, + post_logout_redirect_uris:, + enabled:, + type:, + device_flow:, + team_id:, + user_id:, + installation_scopes:, + installation_redirect_url:, + secrets: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @description = description + @client_uri = client_uri + @logo_uri = logo_uri + @privacy_policy_url = privacy_policy_url + @terms_url = terms_url + @contacts = contacts + @tagline = tagline + @tags = tags + @labels = labels + @images = images + @support_url = support_url + @data_deletion_url = data_deletion_url + @redirect_uris = redirect_uris + @post_logout_redirect_uris = post_logout_redirect_uris + @enabled = enabled + @type = type + @device_flow = device_flow + @team_id = team_id + @user_id = user_id + @installation_scopes = installation_scopes + @installation_redirect_url = installation_redirect_url + @secrets = secrets + end + + def self.from(map:) + App.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + description: map["description"], + client_uri: map["clientUri"], + logo_uri: map["logoUri"], + privacy_policy_url: map["privacyPolicyUrl"], + terms_url: map["termsUrl"], + contacts: map["contacts"], + tagline: map["tagline"], + tags: map["tags"], + labels: map["labels"], + images: map["images"], + support_url: map["supportUrl"], + data_deletion_url: map["dataDeletionUrl"], + redirect_uris: map["redirectUris"], + post_logout_redirect_uris: map["postLogoutRedirectUris"], + enabled: map["enabled"], + type: map["type"], + device_flow: map["deviceFlow"], + team_id: map["teamId"], + user_id: map["userId"], + installation_scopes: map["installationScopes"], + installation_redirect_url: map["installationRedirectUrl"], + secrets: map["secrets"].map { |it| AppSecret.from(map: it) } + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "description": @description, + "clientUri": @client_uri, + "logoUri": @logo_uri, + "privacyPolicyUrl": @privacy_policy_url, + "termsUrl": @terms_url, + "contacts": @contacts, + "tagline": @tagline, + "tags": @tags, + "labels": @labels, + "images": @images, + "supportUrl": @support_url, + "dataDeletionUrl": @data_deletion_url, + "redirectUris": @redirect_uris, + "postLogoutRedirectUris": @post_logout_redirect_uris, + "enabled": @enabled, + "type": @type, + "deviceFlow": @device_flow, + "teamId": @team_id, + "userId": @user_id, + "installationScopes": @installation_scopes, + "installationRedirectUrl": @installation_redirect_url, + "secrets": @secrets.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/app_installation.rb b/lib/appwrite/models/app_installation.rb new file mode 100644 index 00000000..e369d232 --- /dev/null +++ b/lib/appwrite/models/app_installation.rb @@ -0,0 +1,72 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class AppInstallation + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :app_id + attr_reader :team_id + attr_reader :scopes + attr_reader :authorization_details + attr_reader :created_by_id + attr_reader :created_by_name + attr_reader :last_accessed_at + + def initialize( + id:, + created_at:, + updated_at:, + app_id:, + team_id:, + scopes:, + authorization_details:, + created_by_id:, + created_by_name:, + last_accessed_at: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @app_id = app_id + @team_id = team_id + @scopes = scopes + @authorization_details = authorization_details + @created_by_id = created_by_id + @created_by_name = created_by_name + @last_accessed_at = last_accessed_at + end + + def self.from(map:) + AppInstallation.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + app_id: map["appId"], + team_id: map["teamId"], + scopes: map["scopes"], + authorization_details: map["authorizationDetails"], + created_by_id: map["createdById"], + created_by_name: map["createdByName"], + last_accessed_at: map["lastAccessedAt"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "appId": @app_id, + "teamId": @team_id, + "scopes": @scopes, + "authorizationDetails": @authorization_details, + "createdById": @created_by_id, + "createdByName": @created_by_name, + "lastAccessedAt": @last_accessed_at + } + end + end + end +end diff --git a/lib/appwrite/models/app_installation_list.rb b/lib/appwrite/models/app_installation_list.rb new file mode 100644 index 00000000..1c0f16fa --- /dev/null +++ b/lib/appwrite/models/app_installation_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class AppInstallationList + attr_reader :total + attr_reader :installations + + def initialize( + total:, + installations: + ) + @total = total + @installations = installations + end + + def self.from(map:) + AppInstallationList.new( + total: map["total"], + installations: map["installations"].map { |it| AppInstallation.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "installations": @installations.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/app_key.rb b/lib/appwrite/models/app_key.rb new file mode 100644 index 00000000..a9f1c28a --- /dev/null +++ b/lib/appwrite/models/app_key.rb @@ -0,0 +1,67 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class AppKey + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :app_id + attr_reader :secret + attr_reader :hint + attr_reader :created_by_id + attr_reader :created_by_name + attr_reader :last_accessed_at + + def initialize( + id:, + created_at:, + updated_at:, + app_id:, + secret:, + hint:, + created_by_id:, + created_by_name:, + last_accessed_at: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @app_id = app_id + @secret = secret + @hint = hint + @created_by_id = created_by_id + @created_by_name = created_by_name + @last_accessed_at = last_accessed_at + end + + def self.from(map:) + AppKey.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + app_id: map["appId"], + secret: map["secret"], + hint: map["hint"], + created_by_id: map["createdById"], + created_by_name: map["createdByName"], + last_accessed_at: map["lastAccessedAt"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "appId": @app_id, + "secret": @secret, + "hint": @hint, + "createdById": @created_by_id, + "createdByName": @created_by_name, + "lastAccessedAt": @last_accessed_at + } + end + end + end +end diff --git a/lib/appwrite/models/app_key_list.rb b/lib/appwrite/models/app_key_list.rb new file mode 100644 index 00000000..6d3198f5 --- /dev/null +++ b/lib/appwrite/models/app_key_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class AppKeyList + attr_reader :total + attr_reader :keys + + def initialize( + total:, + keys: + ) + @total = total + @keys = keys + end + + def self.from(map:) + AppKeyList.new( + total: map["total"], + keys: map["keys"].map { |it| AppKey.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "keys": @keys.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/app_scope.rb b/lib/appwrite/models/app_scope.rb new file mode 100644 index 00000000..5044bb68 --- /dev/null +++ b/lib/appwrite/models/app_scope.rb @@ -0,0 +1,47 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class AppScope + attr_reader :value + attr_reader :description + attr_reader :type + attr_reader :category + attr_reader :deprecated + + def initialize( + value:, + description:, + type:, + category:, + deprecated: + ) + @value = value + @description = description + @type = type + @category = category + @deprecated = deprecated + end + + def self.from(map:) + AppScope.new( + value: map["value"], + description: map["description"], + type: map["type"], + category: map["category"], + deprecated: map["deprecated"] + ) + end + + def to_map + { + "value": @value, + "description": @description, + "type": @type, + "category": @category, + "deprecated": @deprecated + } + end + end + end +end diff --git a/lib/appwrite/models/app_scope_list.rb b/lib/appwrite/models/app_scope_list.rb new file mode 100644 index 00000000..21d13fb8 --- /dev/null +++ b/lib/appwrite/models/app_scope_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class AppScopeList + attr_reader :total + attr_reader :scopes + + def initialize( + total:, + scopes: + ) + @total = total + @scopes = scopes + end + + def self.from(map:) + AppScopeList.new( + total: map["total"], + scopes: map["scopes"].map { |it| AppScope.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "scopes": @scopes.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/app_secret.rb b/lib/appwrite/models/app_secret.rb new file mode 100644 index 00000000..7f5aa95a --- /dev/null +++ b/lib/appwrite/models/app_secret.rb @@ -0,0 +1,67 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class AppSecret + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :app_id + attr_reader :secret + attr_reader :hint + attr_reader :created_by_id + attr_reader :created_by_name + attr_reader :last_accessed_at + + def initialize( + id:, + created_at:, + updated_at:, + app_id:, + secret:, + hint:, + created_by_id:, + created_by_name:, + last_accessed_at: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @app_id = app_id + @secret = secret + @hint = hint + @created_by_id = created_by_id + @created_by_name = created_by_name + @last_accessed_at = last_accessed_at + end + + def self.from(map:) + AppSecret.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + app_id: map["appId"], + secret: map["secret"], + hint: map["hint"], + created_by_id: map["createdById"], + created_by_name: map["createdByName"], + last_accessed_at: map["lastAccessedAt"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "appId": @app_id, + "secret": @secret, + "hint": @hint, + "createdById": @created_by_id, + "createdByName": @created_by_name, + "lastAccessedAt": @last_accessed_at + } + end + end + end +end diff --git a/lib/appwrite/models/app_secret_list.rb b/lib/appwrite/models/app_secret_list.rb new file mode 100644 index 00000000..09a33029 --- /dev/null +++ b/lib/appwrite/models/app_secret_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class AppSecretList + attr_reader :total + attr_reader :secrets + + def initialize( + total:, + secrets: + ) + @total = total + @secrets = secrets + end + + def self.from(map:) + AppSecretList.new( + total: map["total"], + secrets: map["secrets"].map { |it| AppSecret.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "secrets": @secrets.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/app_secret_plaintext.rb b/lib/appwrite/models/app_secret_plaintext.rb new file mode 100644 index 00000000..9060824f --- /dev/null +++ b/lib/appwrite/models/app_secret_plaintext.rb @@ -0,0 +1,67 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class AppSecretPlaintext + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :app_id + attr_reader :secret + attr_reader :hint + attr_reader :created_by_id + attr_reader :created_by_name + attr_reader :last_accessed_at + + def initialize( + id:, + created_at:, + updated_at:, + app_id:, + secret:, + hint:, + created_by_id:, + created_by_name:, + last_accessed_at: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @app_id = app_id + @secret = secret + @hint = hint + @created_by_id = created_by_id + @created_by_name = created_by_name + @last_accessed_at = last_accessed_at + end + + def self.from(map:) + AppSecretPlaintext.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + app_id: map["appId"], + secret: map["secret"], + hint: map["hint"], + created_by_id: map["createdById"], + created_by_name: map["createdByName"], + last_accessed_at: map["lastAccessedAt"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "appId": @app_id, + "secret": @secret, + "hint": @hint, + "createdById": @created_by_id, + "createdByName": @created_by_name, + "lastAccessedAt": @last_accessed_at + } + end + end + end +end diff --git a/lib/appwrite/models/apps_list.rb b/lib/appwrite/models/apps_list.rb new file mode 100644 index 00000000..cf911684 --- /dev/null +++ b/lib/appwrite/models/apps_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class AppsList + attr_reader :total + attr_reader :apps + + def initialize( + total:, + apps: + ) + @total = total + @apps = apps + end + + def self.from(map:) + AppsList.new( + total: map["total"], + apps: map["apps"].map { |it| App.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "apps": @apps.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/billing_plan.rb b/lib/appwrite/models/billing_plan.rb index ad31ce7f..aac36f6f 100644 --- a/lib/appwrite/models/billing_plan.rb +++ b/lib/appwrite/models/billing_plan.rb @@ -15,6 +15,7 @@ class BillingPlan attr_reader :screenshots_generated attr_reader :members attr_reader :webhooks + attr_reader :waf_rules attr_reader :projects attr_reader :platforms attr_reader :users @@ -85,6 +86,7 @@ def initialize( screenshots_generated:, members:, webhooks:, + waf_rules:, projects:, platforms:, users:, @@ -154,6 +156,7 @@ def initialize( @screenshots_generated = screenshots_generated @members = members @webhooks = webhooks + @waf_rules = waf_rules @projects = projects @platforms = platforms @users = users @@ -226,6 +229,7 @@ def self.from(map:) screenshots_generated: map["screenshotsGenerated"], members: map["members"], webhooks: map["webhooks"], + waf_rules: map["wafRules"], projects: map["projects"], platforms: map["platforms"], users: map["users"], @@ -299,6 +303,7 @@ def to_map "screenshotsGenerated": @screenshots_generated, "members": @members, "webhooks": @webhooks, + "wafRules": @waf_rules, "projects": @projects, "platforms": @platforms, "users": @users, diff --git a/lib/appwrite/models/database.rb b/lib/appwrite/models/database.rb index 015903f1..90e95d6e 100644 --- a/lib/appwrite/models/database.rb +++ b/lib/appwrite/models/database.rb @@ -10,6 +10,9 @@ class Database attr_reader :enabled attr_reader :type attr_reader :status + attr_reader :engine + attr_reader :specification + attr_reader :replicas attr_reader :policies attr_reader :archives @@ -21,8 +24,11 @@ def initialize( enabled:, type:, status: , - policies:, - archives: + engine: , + specification: , + replicas: , + policies: , + archives: ) @id = id @name = name @@ -31,6 +37,9 @@ def initialize( @enabled = enabled @type = validate_type(type) @status = status.nil? ? status : validate_status(status) + @engine = engine + @specification = specification + @replicas = replicas @policies = policies @archives = archives end @@ -44,8 +53,11 @@ def self.from(map:) enabled: map["enabled"], type: map["type"], status: map["status"], - policies: map["policies"].map { |it| BackupPolicy.from(map: it) }, - archives: map["archives"].map { |it| BackupArchive.from(map: it) } + engine: map["engine"], + specification: map["specification"], + replicas: map["replicas"], + policies: map["policies"]&.map { |it| BackupPolicy.from(map: it) }, + archives: map["archives"]&.map { |it| BackupArchive.from(map: it) } ) end @@ -58,8 +70,11 @@ def to_map "enabled": @enabled, "type": @type, "status": @status, - "policies": @policies.map { |it| it.to_map }, - "archives": @archives.map { |it| it.to_map } + "engine": @engine, + "specification": @specification, + "replicas": @replicas, + "policies": @policies&.map { |it| it.to_map }, + "archives": @archives&.map { |it| it.to_map } } end @@ -71,6 +86,9 @@ def validate_type(type) Appwrite::Enums::DatabaseType::TABLESDB, Appwrite::Enums::DatabaseType::DOCUMENTSDB, Appwrite::Enums::DatabaseType::VECTORSDB, + Appwrite::Enums::DatabaseType::MYSQL, + Appwrite::Enums::DatabaseType::POSTGRESQL, + Appwrite::Enums::DatabaseType::MONGODB, ] unless valid_type.include?(type) @@ -84,7 +102,18 @@ def validate_status(status) valid_status = [ Appwrite::Enums::DatabaseStatus::PROVISIONING, Appwrite::Enums::DatabaseStatus::READY, + Appwrite::Enums::DatabaseStatus::INACTIVE, + Appwrite::Enums::DatabaseStatus::PAUSED, Appwrite::Enums::DatabaseStatus::FAILED, + Appwrite::Enums::DatabaseStatus::DELETING, + Appwrite::Enums::DatabaseStatus::DELETED, + Appwrite::Enums::DatabaseStatus::RESTORING, + Appwrite::Enums::DatabaseStatus::SCALING, + Appwrite::Enums::DatabaseStatus::UPGRADING, + Appwrite::Enums::DatabaseStatus::MIGRATING, + Appwrite::Enums::DatabaseStatus::PAUSING, + Appwrite::Enums::DatabaseStatus::RESUMING, + Appwrite::Enums::DatabaseStatus::FAILING_OVER, ] unless valid_status.include?(status) diff --git a/lib/appwrite/models/database_status.rb b/lib/appwrite/models/database_status.rb new file mode 100644 index 00000000..3807f173 --- /dev/null +++ b/lib/appwrite/models/database_status.rb @@ -0,0 +1,62 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class DatabaseStatus + attr_reader :health + attr_reader :ready + attr_reader :engine + attr_reader :version + attr_reader :uptime + attr_reader :connections + attr_reader :replicas + attr_reader :volumes + + def initialize( + health:, + ready:, + engine:, + version:, + uptime:, + connections:, + replicas:, + volumes: + ) + @health = health + @ready = ready + @engine = engine + @version = version + @uptime = uptime + @connections = connections + @replicas = replicas + @volumes = volumes + end + + def self.from(map:) + DatabaseStatus.new( + health: map["health"], + ready: map["ready"], + engine: map["engine"], + version: map["version"], + uptime: map["uptime"], + connections: DatabaseStatusConnections.from(map: map["connections"]), + replicas: map["replicas"].map { |it| DatabaseStatusReplica.from(map: it) }, + volumes: map["volumes"].map { |it| DatabaseStatusVolume.from(map: it) } + ) + end + + def to_map + { + "health": @health, + "ready": @ready, + "engine": @engine, + "version": @version, + "uptime": @uptime, + "connections": @connections.to_map, + "replicas": @replicas.map { |it| it.to_map }, + "volumes": @volumes.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/database_status_connections.rb b/lib/appwrite/models/database_status_connections.rb new file mode 100644 index 00000000..bbf23950 --- /dev/null +++ b/lib/appwrite/models/database_status_connections.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class DatabaseStatusConnections + attr_reader :current + attr_reader :max + + def initialize( + current:, + max: + ) + @current = current + @max = max + end + + def self.from(map:) + DatabaseStatusConnections.new( + current: map["current"], + max: map["max"] + ) + end + + def to_map + { + "current": @current, + "max": @max + } + end + end + end +end diff --git a/lib/appwrite/models/database_status_replica.rb b/lib/appwrite/models/database_status_replica.rb new file mode 100644 index 00000000..d88c2cb3 --- /dev/null +++ b/lib/appwrite/models/database_status_replica.rb @@ -0,0 +1,42 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class DatabaseStatusReplica + attr_reader :index + attr_reader :role + attr_reader :healthy + attr_reader :lag_seconds + + def initialize( + index:, + role:, + healthy:, + lag_seconds: + ) + @index = index + @role = role + @healthy = healthy + @lag_seconds = lag_seconds + end + + def self.from(map:) + DatabaseStatusReplica.new( + index: map["index"], + role: map["role"], + healthy: map["healthy"], + lag_seconds: map["lagSeconds"] + ) + end + + def to_map + { + "index": @index, + "role": @role, + "healthy": @healthy, + "lagSeconds": @lag_seconds + } + end + end + end +end diff --git a/lib/appwrite/models/database_status_volume.rb b/lib/appwrite/models/database_status_volume.rb new file mode 100644 index 00000000..7ace12c9 --- /dev/null +++ b/lib/appwrite/models/database_status_volume.rb @@ -0,0 +1,42 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class DatabaseStatusVolume + attr_reader :xpath + attr_reader :used_percent + attr_reader :available + attr_reader :mounted + + def initialize( + xpath:, + used_percent:, + available:, + mounted: + ) + @xpath = xpath + @used_percent = used_percent + @available = available + @mounted = mounted + end + + def self.from(map:) + DatabaseStatusVolume.new( + xpath: map["path"], + used_percent: map["usedPercent"], + available: map["available"], + mounted: map["mounted"] + ) + end + + def to_map + { + "path": @xpath, + "usedPercent": @used_percent, + "available": @available, + "mounted": @mounted + } + end + end + end +end diff --git a/lib/appwrite/models/dedicated_database.rb b/lib/appwrite/models/dedicated_database.rb new file mode 100644 index 00000000..43d3e8d8 --- /dev/null +++ b/lib/appwrite/models/dedicated_database.rb @@ -0,0 +1,267 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class DedicatedDatabase + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :project_id + attr_reader :name + attr_reader :api + attr_reader :engine + attr_reader :version + attr_reader :specification + attr_reader :backend + attr_reader :hostname + attr_reader :connection_port + attr_reader :connection_user + attr_reader :connection_password + attr_reader :connection_string + attr_reader :ssl + attr_reader :status + attr_reader :container_status + attr_reader :last_accessed_at + attr_reader :idle_until + attr_reader :lifecycle_state + attr_reader :idle_timeout_minutes + attr_reader :cpu + attr_reader :memory + attr_reader :storage + attr_reader :storage_class + attr_reader :storage_max_gb + attr_reader :node_pool + attr_reader :replicas + attr_reader :sync_mode + attr_reader :cross_region_replicas + attr_reader :network_max_connections + attr_reader :network_idle_timeout_seconds + attr_reader :network_ip_allowlist + attr_reader :backup_enabled + attr_reader :pitr + attr_reader :pitr_retention_days + attr_reader :storage_autoscaling + attr_reader :storage_autoscaling_threshold_percent + attr_reader :storage_autoscaling_max_gb + attr_reader :maintenance_window_day + attr_reader :maintenance_window_hour_utc + attr_reader :metrics_enabled + attr_reader :sql_api_enabled + attr_reader :sql_api_allowed_statements + attr_reader :sql_api_max_rows + attr_reader :sql_api_max_bytes + attr_reader :sql_api_timeout_seconds + attr_reader :error + + def initialize( + id:, + created_at:, + updated_at:, + project_id:, + name:, + api:, + engine:, + version:, + specification:, + backend:, + hostname:, + connection_port:, + connection_user:, + connection_password:, + connection_string:, + ssl:, + status:, + container_status:, + last_accessed_at: , + idle_until: , + lifecycle_state:, + idle_timeout_minutes:, + cpu:, + memory:, + storage:, + storage_class:, + storage_max_gb:, + node_pool:, + replicas:, + sync_mode:, + cross_region_replicas:, + network_max_connections:, + network_idle_timeout_seconds:, + network_ip_allowlist:, + backup_enabled:, + pitr:, + pitr_retention_days:, + storage_autoscaling:, + storage_autoscaling_threshold_percent:, + storage_autoscaling_max_gb:, + maintenance_window_day:, + maintenance_window_hour_utc:, + metrics_enabled:, + sql_api_enabled:, + sql_api_allowed_statements:, + sql_api_max_rows:, + sql_api_max_bytes:, + sql_api_timeout_seconds:, + error: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @project_id = project_id + @name = name + @api = api + @engine = engine + @version = version + @specification = specification + @backend = backend + @hostname = hostname + @connection_port = connection_port + @connection_user = connection_user + @connection_password = connection_password + @connection_string = connection_string + @ssl = ssl + @status = status + @container_status = container_status + @last_accessed_at = last_accessed_at + @idle_until = idle_until + @lifecycle_state = lifecycle_state + @idle_timeout_minutes = idle_timeout_minutes + @cpu = cpu + @memory = memory + @storage = storage + @storage_class = storage_class + @storage_max_gb = storage_max_gb + @node_pool = node_pool + @replicas = replicas + @sync_mode = sync_mode + @cross_region_replicas = cross_region_replicas + @network_max_connections = network_max_connections + @network_idle_timeout_seconds = network_idle_timeout_seconds + @network_ip_allowlist = network_ip_allowlist + @backup_enabled = backup_enabled + @pitr = pitr + @pitr_retention_days = pitr_retention_days + @storage_autoscaling = storage_autoscaling + @storage_autoscaling_threshold_percent = storage_autoscaling_threshold_percent + @storage_autoscaling_max_gb = storage_autoscaling_max_gb + @maintenance_window_day = maintenance_window_day + @maintenance_window_hour_utc = maintenance_window_hour_utc + @metrics_enabled = metrics_enabled + @sql_api_enabled = sql_api_enabled + @sql_api_allowed_statements = sql_api_allowed_statements + @sql_api_max_rows = sql_api_max_rows + @sql_api_max_bytes = sql_api_max_bytes + @sql_api_timeout_seconds = sql_api_timeout_seconds + @error = error + end + + def self.from(map:) + DedicatedDatabase.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + project_id: map["projectId"], + name: map["name"], + api: map["api"], + engine: map["engine"], + version: map["version"], + specification: map["specification"], + backend: map["backend"], + hostname: map["hostname"], + connection_port: map["connectionPort"], + connection_user: map["connectionUser"], + connection_password: map["connectionPassword"], + connection_string: map["connectionString"], + ssl: map["ssl"], + status: map["status"], + container_status: map["containerStatus"], + last_accessed_at: map["lastAccessedAt"], + idle_until: map["idleUntil"], + lifecycle_state: map["lifecycleState"], + idle_timeout_minutes: map["idleTimeoutMinutes"], + cpu: map["cpu"], + memory: map["memory"], + storage: map["storage"], + storage_class: map["storageClass"], + storage_max_gb: map["storageMaxGb"], + node_pool: map["nodePool"], + replicas: map["replicas"], + sync_mode: map["syncMode"], + cross_region_replicas: map["crossRegionReplicas"], + network_max_connections: map["networkMaxConnections"], + network_idle_timeout_seconds: map["networkIdleTimeoutSeconds"], + network_ip_allowlist: map["networkIPAllowlist"], + backup_enabled: map["backupEnabled"], + pitr: map["pitr"], + pitr_retention_days: map["pitrRetentionDays"], + storage_autoscaling: map["storageAutoscaling"], + storage_autoscaling_threshold_percent: map["storageAutoscalingThresholdPercent"], + storage_autoscaling_max_gb: map["storageAutoscalingMaxGb"], + maintenance_window_day: map["maintenanceWindowDay"], + maintenance_window_hour_utc: map["maintenanceWindowHourUtc"], + metrics_enabled: map["metricsEnabled"], + sql_api_enabled: map["sqlApiEnabled"], + sql_api_allowed_statements: map["sqlApiAllowedStatements"], + sql_api_max_rows: map["sqlApiMaxRows"], + sql_api_max_bytes: map["sqlApiMaxBytes"], + sql_api_timeout_seconds: map["sqlApiTimeoutSeconds"], + error: map["error"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "projectId": @project_id, + "name": @name, + "api": @api, + "engine": @engine, + "version": @version, + "specification": @specification, + "backend": @backend, + "hostname": @hostname, + "connectionPort": @connection_port, + "connectionUser": @connection_user, + "connectionPassword": @connection_password, + "connectionString": @connection_string, + "ssl": @ssl, + "status": @status, + "containerStatus": @container_status, + "lastAccessedAt": @last_accessed_at, + "idleUntil": @idle_until, + "lifecycleState": @lifecycle_state, + "idleTimeoutMinutes": @idle_timeout_minutes, + "cpu": @cpu, + "memory": @memory, + "storage": @storage, + "storageClass": @storage_class, + "storageMaxGb": @storage_max_gb, + "nodePool": @node_pool, + "replicas": @replicas, + "syncMode": @sync_mode, + "crossRegionReplicas": @cross_region_replicas, + "networkMaxConnections": @network_max_connections, + "networkIdleTimeoutSeconds": @network_idle_timeout_seconds, + "networkIPAllowlist": @network_ip_allowlist, + "backupEnabled": @backup_enabled, + "pitr": @pitr, + "pitrRetentionDays": @pitr_retention_days, + "storageAutoscaling": @storage_autoscaling, + "storageAutoscalingThresholdPercent": @storage_autoscaling_threshold_percent, + "storageAutoscalingMaxGb": @storage_autoscaling_max_gb, + "maintenanceWindowDay": @maintenance_window_day, + "maintenanceWindowHourUtc": @maintenance_window_hour_utc, + "metricsEnabled": @metrics_enabled, + "sqlApiEnabled": @sql_api_enabled, + "sqlApiAllowedStatements": @sql_api_allowed_statements, + "sqlApiMaxRows": @sql_api_max_rows, + "sqlApiMaxBytes": @sql_api_max_bytes, + "sqlApiTimeoutSeconds": @sql_api_timeout_seconds, + "error": @error + } + end + end + end +end diff --git a/lib/appwrite/models/dedicated_database_member.rb b/lib/appwrite/models/dedicated_database_member.rb new file mode 100644 index 00000000..3f88817b --- /dev/null +++ b/lib/appwrite/models/dedicated_database_member.rb @@ -0,0 +1,42 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class DedicatedDatabaseMember + attr_reader :id + attr_reader :role + attr_reader :status + attr_reader :lag_seconds + + def initialize( + id:, + role:, + status:, + lag_seconds: + ) + @id = id + @role = role + @status = status + @lag_seconds = lag_seconds + end + + def self.from(map:) + DedicatedDatabaseMember.new( + id: map["$id"], + role: map["role"], + status: map["status"], + lag_seconds: map["lagSeconds"] + ) + end + + def to_map + { + "$id": @id, + "role": @role, + "status": @status, + "lagSeconds": @lag_seconds + } + end + end + end +end diff --git a/lib/appwrite/models/dedicated_database_replicas.rb b/lib/appwrite/models/dedicated_database_replicas.rb new file mode 100644 index 00000000..3cbdc5cc --- /dev/null +++ b/lib/appwrite/models/dedicated_database_replicas.rb @@ -0,0 +1,37 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class DedicatedDatabaseReplicas + attr_reader :replicas + attr_reader :sync_mode + attr_reader :members + + def initialize( + replicas:, + sync_mode:, + members: + ) + @replicas = replicas + @sync_mode = sync_mode + @members = members + end + + def self.from(map:) + DedicatedDatabaseReplicas.new( + replicas: map["replicas"], + sync_mode: map["syncMode"], + members: map["members"].map { |it| DedicatedDatabaseMember.from(map: it) } + ) + end + + def to_map + { + "replicas": @replicas, + "syncMode": @sync_mode, + "members": @members.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/dedicated_database_specification.rb b/lib/appwrite/models/dedicated_database_specification.rb new file mode 100644 index 00000000..ceb55948 --- /dev/null +++ b/lib/appwrite/models/dedicated_database_specification.rb @@ -0,0 +1,67 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class DedicatedDatabaseSpecification + attr_reader :slug + attr_reader :name + attr_reader :price + attr_reader :cpu + attr_reader :memory + attr_reader :max_connections + attr_reader :included_storage + attr_reader :included_bandwidth + attr_reader :enabled + + def initialize( + slug:, + name:, + price:, + cpu:, + memory:, + max_connections:, + included_storage:, + included_bandwidth:, + enabled: + ) + @slug = slug + @name = name + @price = price + @cpu = cpu + @memory = memory + @max_connections = max_connections + @included_storage = included_storage + @included_bandwidth = included_bandwidth + @enabled = enabled + end + + def self.from(map:) + DedicatedDatabaseSpecification.new( + slug: map["slug"], + name: map["name"], + price: map["price"], + cpu: map["cpu"], + memory: map["memory"], + max_connections: map["maxConnections"], + included_storage: map["includedStorage"], + included_bandwidth: map["includedBandwidth"], + enabled: map["enabled"] + ) + end + + def to_map + { + "slug": @slug, + "name": @name, + "price": @price, + "cpu": @cpu, + "memory": @memory, + "maxConnections": @max_connections, + "includedStorage": @included_storage, + "includedBandwidth": @included_bandwidth, + "enabled": @enabled + } + end + end + end +end diff --git a/lib/appwrite/models/dedicated_database_specification_list.rb b/lib/appwrite/models/dedicated_database_specification_list.rb new file mode 100644 index 00000000..7201593c --- /dev/null +++ b/lib/appwrite/models/dedicated_database_specification_list.rb @@ -0,0 +1,37 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class DedicatedDatabaseSpecificationList + attr_reader :specifications + attr_reader :total + attr_reader :pricing + + def initialize( + specifications:, + total:, + pricing: + ) + @specifications = specifications + @total = total + @pricing = pricing + end + + def self.from(map:) + DedicatedDatabaseSpecificationList.new( + specifications: map["specifications"].map { |it| DedicatedDatabaseSpecification.from(map: it) }, + total: map["total"], + pricing: DedicatedDatabaseSpecificationPricing.from(map: map["pricing"]) + ) + end + + def to_map + { + "specifications": @specifications.map { |it| it.to_map }, + "total": @total, + "pricing": @pricing.to_map + } + end + end + end +end diff --git a/lib/appwrite/models/dedicated_database_specification_pricing.rb b/lib/appwrite/models/dedicated_database_specification_pricing.rb new file mode 100644 index 00000000..ed68de88 --- /dev/null +++ b/lib/appwrite/models/dedicated_database_specification_pricing.rb @@ -0,0 +1,47 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class DedicatedDatabaseSpecificationPricing + attr_reader :storage_overage_rate + attr_reader :bandwidth_overage_rate + attr_reader :replica_rate + attr_reader :cross_region_replica_rate + attr_reader :pitr_rate + + def initialize( + storage_overage_rate:, + bandwidth_overage_rate:, + replica_rate:, + cross_region_replica_rate:, + pitr_rate: + ) + @storage_overage_rate = storage_overage_rate + @bandwidth_overage_rate = bandwidth_overage_rate + @replica_rate = replica_rate + @cross_region_replica_rate = cross_region_replica_rate + @pitr_rate = pitr_rate + end + + def self.from(map:) + DedicatedDatabaseSpecificationPricing.new( + storage_overage_rate: map["storageOverageRate"], + bandwidth_overage_rate: map["bandwidthOverageRate"], + replica_rate: map["replicaRate"], + cross_region_replica_rate: map["crossRegionReplicaRate"], + pitr_rate: map["pitrRate"] + ) + end + + def to_map + { + "storageOverageRate": @storage_overage_rate, + "bandwidthOverageRate": @bandwidth_overage_rate, + "replicaRate": @replica_rate, + "crossRegionReplicaRate": @cross_region_replica_rate, + "pitrRate": @pitr_rate + } + end + end + end +end diff --git a/lib/appwrite/models/oauth2_approve.rb b/lib/appwrite/models/oauth2_approve.rb new file mode 100644 index 00000000..a1539195 --- /dev/null +++ b/lib/appwrite/models/oauth2_approve.rb @@ -0,0 +1,27 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Oauth2Approve + attr_reader :redirect_url + + def initialize( + redirect_url: + ) + @redirect_url = redirect_url + end + + def self.from(map:) + Oauth2Approve.new( + redirect_url: map["redirectUrl"] + ) + end + + def to_map + { + "redirectUrl": @redirect_url + } + end + end + end +end diff --git a/lib/appwrite/models/oauth2_authorize.rb b/lib/appwrite/models/oauth2_authorize.rb new file mode 100644 index 00000000..82a0c3c8 --- /dev/null +++ b/lib/appwrite/models/oauth2_authorize.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Oauth2Authorize + attr_reader :grant_id + attr_reader :redirect_url + + def initialize( + grant_id:, + redirect_url: + ) + @grant_id = grant_id + @redirect_url = redirect_url + end + + def self.from(map:) + Oauth2Authorize.new( + grant_id: map["grantId"], + redirect_url: map["redirectUrl"] + ) + end + + def to_map + { + "grantId": @grant_id, + "redirectUrl": @redirect_url + } + end + end + end +end diff --git a/lib/appwrite/models/oauth2_consent.rb b/lib/appwrite/models/oauth2_consent.rb new file mode 100644 index 00000000..7387dddf --- /dev/null +++ b/lib/appwrite/models/oauth2_consent.rb @@ -0,0 +1,72 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Oauth2Consent + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :user_id + attr_reader :app_id + attr_reader :cimd_url + attr_reader :scopes + attr_reader :resources + attr_reader :authorization_details + attr_reader :expire + + def initialize( + id:, + created_at:, + updated_at:, + user_id:, + app_id:, + cimd_url:, + scopes:, + resources:, + authorization_details:, + expire: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @user_id = user_id + @app_id = app_id + @cimd_url = cimd_url + @scopes = scopes + @resources = resources + @authorization_details = authorization_details + @expire = expire + end + + def self.from(map:) + Oauth2Consent.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + user_id: map["userId"], + app_id: map["appId"], + cimd_url: map["cimdUrl"], + scopes: map["scopes"], + resources: map["resources"], + authorization_details: map["authorizationDetails"], + expire: map["expire"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "userId": @user_id, + "appId": @app_id, + "cimdUrl": @cimd_url, + "scopes": @scopes, + "resources": @resources, + "authorizationDetails": @authorization_details, + "expire": @expire + } + end + end + end +end diff --git a/lib/appwrite/models/oauth2_consent_list.rb b/lib/appwrite/models/oauth2_consent_list.rb new file mode 100644 index 00000000..6d48dd80 --- /dev/null +++ b/lib/appwrite/models/oauth2_consent_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Oauth2ConsentList + attr_reader :total + attr_reader :consents + + def initialize( + total:, + consents: + ) + @total = total + @consents = consents + end + + def self.from(map:) + Oauth2ConsentList.new( + total: map["total"], + consents: map["consents"].map { |it| Oauth2Consent.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "consents": @consents.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/oauth2_consent_token.rb b/lib/appwrite/models/oauth2_consent_token.rb new file mode 100644 index 00000000..b98a9429 --- /dev/null +++ b/lib/appwrite/models/oauth2_consent_token.rb @@ -0,0 +1,77 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Oauth2ConsentToken + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :consent_id + attr_reader :user_id + attr_reader :app_id + attr_reader :cimd_url + attr_reader :scopes + attr_reader :resources + attr_reader :authorization_details + attr_reader :expire + + def initialize( + id:, + created_at:, + updated_at:, + consent_id:, + user_id:, + app_id:, + cimd_url:, + scopes:, + resources:, + authorization_details:, + expire: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @consent_id = consent_id + @user_id = user_id + @app_id = app_id + @cimd_url = cimd_url + @scopes = scopes + @resources = resources + @authorization_details = authorization_details + @expire = expire + end + + def self.from(map:) + Oauth2ConsentToken.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + consent_id: map["consentId"], + user_id: map["userId"], + app_id: map["appId"], + cimd_url: map["cimdUrl"], + scopes: map["scopes"], + resources: map["resources"], + authorization_details: map["authorizationDetails"], + expire: map["expire"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "consentId": @consent_id, + "userId": @user_id, + "appId": @app_id, + "cimdUrl": @cimd_url, + "scopes": @scopes, + "resources": @resources, + "authorizationDetails": @authorization_details, + "expire": @expire + } + end + end + end +end diff --git a/lib/appwrite/models/oauth2_consent_token_list.rb b/lib/appwrite/models/oauth2_consent_token_list.rb new file mode 100644 index 00000000..a06536e2 --- /dev/null +++ b/lib/appwrite/models/oauth2_consent_token_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Oauth2ConsentTokenList + attr_reader :total + attr_reader :tokens + + def initialize( + total:, + tokens: + ) + @total = total + @tokens = tokens + end + + def self.from(map:) + Oauth2ConsentTokenList.new( + total: map["total"], + tokens: map["tokens"].map { |it| Oauth2ConsentToken.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "tokens": @tokens.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/oauth2_device_authorization.rb b/lib/appwrite/models/oauth2_device_authorization.rb new file mode 100644 index 00000000..c50e3713 --- /dev/null +++ b/lib/appwrite/models/oauth2_device_authorization.rb @@ -0,0 +1,52 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Oauth2DeviceAuthorization + attr_reader :device_code + attr_reader :user_code + attr_reader :verification_uri + attr_reader :verification_uri_complete + attr_reader :expires_in + attr_reader :interval + + def initialize( + device_code:, + user_code:, + verification_uri:, + verification_uri_complete:, + expires_in:, + interval: + ) + @device_code = device_code + @user_code = user_code + @verification_uri = verification_uri + @verification_uri_complete = verification_uri_complete + @expires_in = expires_in + @interval = interval + end + + def self.from(map:) + Oauth2DeviceAuthorization.new( + device_code: map["device_code"], + user_code: map["user_code"], + verification_uri: map["verification_uri"], + verification_uri_complete: map["verification_uri_complete"], + expires_in: map["expires_in"], + interval: map["interval"] + ) + end + + def to_map + { + "device_code": @device_code, + "user_code": @user_code, + "verification_uri": @verification_uri, + "verification_uri_complete": @verification_uri_complete, + "expires_in": @expires_in, + "interval": @interval + } + end + end + end +end diff --git a/lib/appwrite/models/oauth2_grant.rb b/lib/appwrite/models/oauth2_grant.rb new file mode 100644 index 00000000..8e87f96c --- /dev/null +++ b/lib/appwrite/models/oauth2_grant.rb @@ -0,0 +1,82 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Oauth2Grant + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :user_id + attr_reader :app_id + attr_reader :scopes + attr_reader :resources + attr_reader :authorization_details + attr_reader :prompt + attr_reader :redirect_uri + attr_reader :auth_time + attr_reader :expire + + def initialize( + id:, + created_at:, + updated_at:, + user_id:, + app_id:, + scopes:, + resources:, + authorization_details:, + prompt:, + redirect_uri:, + auth_time:, + expire: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @user_id = user_id + @app_id = app_id + @scopes = scopes + @resources = resources + @authorization_details = authorization_details + @prompt = prompt + @redirect_uri = redirect_uri + @auth_time = auth_time + @expire = expire + end + + def self.from(map:) + Oauth2Grant.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + user_id: map["userId"], + app_id: map["appId"], + scopes: map["scopes"], + resources: map["resources"], + authorization_details: map["authorizationDetails"], + prompt: map["prompt"], + redirect_uri: map["redirectUri"], + auth_time: map["authTime"], + expire: map["expire"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "userId": @user_id, + "appId": @app_id, + "scopes": @scopes, + "resources": @resources, + "authorizationDetails": @authorization_details, + "prompt": @prompt, + "redirectUri": @redirect_uri, + "authTime": @auth_time, + "expire": @expire + } + end + end + end +end diff --git a/lib/appwrite/models/oauth2_organization.rb b/lib/appwrite/models/oauth2_organization.rb new file mode 100644 index 00000000..c54bc380 --- /dev/null +++ b/lib/appwrite/models/oauth2_organization.rb @@ -0,0 +1,27 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Oauth2Organization + attr_reader :id + + def initialize( + id: + ) + @id = id + end + + def self.from(map:) + Oauth2Organization.new( + id: map["$id"] + ) + end + + def to_map + { + "$id": @id + } + end + end + end +end diff --git a/lib/appwrite/models/oauth2_organization_list.rb b/lib/appwrite/models/oauth2_organization_list.rb new file mode 100644 index 00000000..dd9691b5 --- /dev/null +++ b/lib/appwrite/models/oauth2_organization_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Oauth2OrganizationList + attr_reader :total + attr_reader :organizations + + def initialize( + total:, + organizations: + ) + @total = total + @organizations = organizations + end + + def self.from(map:) + Oauth2OrganizationList.new( + total: map["total"], + organizations: map["organizations"].map { |it| Oauth2Organization.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "organizations": @organizations.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/oauth2_par.rb b/lib/appwrite/models/oauth2_par.rb new file mode 100644 index 00000000..c42f8724 --- /dev/null +++ b/lib/appwrite/models/oauth2_par.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Oauth2PAR + attr_reader :request_uri + attr_reader :expires_in + + def initialize( + request_uri:, + expires_in: + ) + @request_uri = request_uri + @expires_in = expires_in + end + + def self.from(map:) + Oauth2PAR.new( + request_uri: map["request_uri"], + expires_in: map["expires_in"] + ) + end + + def to_map + { + "request_uri": @request_uri, + "expires_in": @expires_in + } + end + end + end +end diff --git a/lib/appwrite/models/oauth2_project.rb b/lib/appwrite/models/oauth2_project.rb new file mode 100644 index 00000000..a3fdf58d --- /dev/null +++ b/lib/appwrite/models/oauth2_project.rb @@ -0,0 +1,37 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Oauth2Project + attr_reader :id + attr_reader :region + attr_reader :endpoint + + def initialize( + id:, + region:, + endpoint: + ) + @id = id + @region = region + @endpoint = endpoint + end + + def self.from(map:) + Oauth2Project.new( + id: map["$id"], + region: map["region"], + endpoint: map["endpoint"] + ) + end + + def to_map + { + "$id": @id, + "region": @region, + "endpoint": @endpoint + } + end + end + end +end diff --git a/lib/appwrite/models/oauth2_project_list.rb b/lib/appwrite/models/oauth2_project_list.rb new file mode 100644 index 00000000..5063b9b0 --- /dev/null +++ b/lib/appwrite/models/oauth2_project_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Oauth2ProjectList + attr_reader :total + attr_reader :projects + + def initialize( + total:, + projects: + ) + @total = total + @projects = projects + end + + def self.from(map:) + Oauth2ProjectList.new( + total: map["total"], + projects: map["projects"].map { |it| Oauth2Project.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "projects": @projects.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/oauth2_reject.rb b/lib/appwrite/models/oauth2_reject.rb new file mode 100644 index 00000000..62f80c40 --- /dev/null +++ b/lib/appwrite/models/oauth2_reject.rb @@ -0,0 +1,27 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Oauth2Reject + attr_reader :redirect_url + + def initialize( + redirect_url: + ) + @redirect_url = redirect_url + end + + def self.from(map:) + Oauth2Reject.new( + redirect_url: map["redirectUrl"] + ) + end + + def to_map + { + "redirectUrl": @redirect_url + } + end + end + end +end diff --git a/lib/appwrite/models/oauth2_token.rb b/lib/appwrite/models/oauth2_token.rb new file mode 100644 index 00000000..db7630c4 --- /dev/null +++ b/lib/appwrite/models/oauth2_token.rb @@ -0,0 +1,57 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Oauth2Token + attr_reader :access_token + attr_reader :token_type + attr_reader :expires_in + attr_reader :refresh_token + attr_reader :scope + attr_reader :authorization_details + attr_reader :id_token + + def initialize( + access_token:, + token_type:, + expires_in:, + refresh_token:, + scope:, + authorization_details: , + id_token: + ) + @access_token = access_token + @token_type = token_type + @expires_in = expires_in + @refresh_token = refresh_token + @scope = scope + @authorization_details = authorization_details + @id_token = id_token + end + + def self.from(map:) + Oauth2Token.new( + access_token: map["access_token"], + token_type: map["token_type"], + expires_in: map["expires_in"], + refresh_token: map["refresh_token"], + scope: map["scope"], + authorization_details: map["authorization_details"], + id_token: map["id_token"] + ) + end + + def to_map + { + "access_token": @access_token, + "token_type": @token_type, + "expires_in": @expires_in, + "refresh_token": @refresh_token, + "scope": @scope, + "authorization_details": @authorization_details, + "id_token": @id_token + } + end + end + end +end diff --git a/lib/appwrite/models/project.rb b/lib/appwrite/models/project.rb index 15d5056a..94f7bb10 100644 --- a/lib/appwrite/models/project.rb +++ b/lib/appwrite/models/project.rb @@ -30,6 +30,7 @@ class Project attr_reader :protocols attr_reader :blocks attr_reader :console_accessed_at + attr_reader :waf_enabled attr_reader :billing_limits attr_reader :o_auth2_server_enabled attr_reader :o_auth2_server_authorization_url @@ -40,6 +41,7 @@ class Project attr_reader :o_auth2_server_refresh_token_duration attr_reader :o_auth2_server_public_access_token_duration attr_reader :o_auth2_server_public_refresh_token_duration + attr_reader :o_auth2_server_installation_access_token_duration attr_reader :o_auth2_server_confidential_pkce attr_reader :o_auth2_server_verification_url attr_reader :o_auth2_server_user_code_length @@ -75,6 +77,7 @@ def initialize( protocols:, blocks:, console_accessed_at:, + waf_enabled:, billing_limits: , o_auth2_server_enabled: , o_auth2_server_authorization_url: , @@ -85,6 +88,7 @@ def initialize( o_auth2_server_refresh_token_duration: , o_auth2_server_public_access_token_duration: , o_auth2_server_public_refresh_token_duration: , + o_auth2_server_installation_access_token_duration: , o_auth2_server_confidential_pkce: , o_auth2_server_verification_url: , o_auth2_server_user_code_length: , @@ -119,6 +123,7 @@ def initialize( @protocols = protocols @blocks = blocks @console_accessed_at = console_accessed_at + @waf_enabled = waf_enabled @billing_limits = billing_limits @o_auth2_server_enabled = o_auth2_server_enabled @o_auth2_server_authorization_url = o_auth2_server_authorization_url @@ -129,6 +134,7 @@ def initialize( @o_auth2_server_refresh_token_duration = o_auth2_server_refresh_token_duration @o_auth2_server_public_access_token_duration = o_auth2_server_public_access_token_duration @o_auth2_server_public_refresh_token_duration = o_auth2_server_public_refresh_token_duration + @o_auth2_server_installation_access_token_duration = o_auth2_server_installation_access_token_duration @o_auth2_server_confidential_pkce = o_auth2_server_confidential_pkce @o_auth2_server_verification_url = o_auth2_server_verification_url @o_auth2_server_user_code_length = o_auth2_server_user_code_length @@ -166,6 +172,7 @@ def self.from(map:) protocols: map["protocols"].map { |it| ProjectProtocol.from(map: it) }, blocks: map["blocks"].map { |it| Block.from(map: it) }, console_accessed_at: map["consoleAccessedAt"], + waf_enabled: map["wafEnabled"], billing_limits: map["billingLimits"].nil? ? nil : BillingLimits.from(map: map["billingLimits"]), o_auth2_server_enabled: map["oAuth2ServerEnabled"], o_auth2_server_authorization_url: map["oAuth2ServerAuthorizationUrl"], @@ -176,6 +183,7 @@ def self.from(map:) o_auth2_server_refresh_token_duration: map["oAuth2ServerRefreshTokenDuration"], o_auth2_server_public_access_token_duration: map["oAuth2ServerPublicAccessTokenDuration"], o_auth2_server_public_refresh_token_duration: map["oAuth2ServerPublicRefreshTokenDuration"], + o_auth2_server_installation_access_token_duration: map["oAuth2ServerInstallationAccessTokenDuration"], o_auth2_server_confidential_pkce: map["oAuth2ServerConfidentialPkce"], o_auth2_server_verification_url: map["oAuth2ServerVerificationUrl"], o_auth2_server_user_code_length: map["oAuth2ServerUserCodeLength"], @@ -214,6 +222,7 @@ def to_map "protocols": @protocols.map { |it| it.to_map }, "blocks": @blocks.map { |it| it.to_map }, "consoleAccessedAt": @console_accessed_at, + "wafEnabled": @waf_enabled, "billingLimits": @billing_limits&.to_map, "oAuth2ServerEnabled": @o_auth2_server_enabled, "oAuth2ServerAuthorizationUrl": @o_auth2_server_authorization_url, @@ -224,6 +233,7 @@ def to_map "oAuth2ServerRefreshTokenDuration": @o_auth2_server_refresh_token_duration, "oAuth2ServerPublicAccessTokenDuration": @o_auth2_server_public_access_token_duration, "oAuth2ServerPublicRefreshTokenDuration": @o_auth2_server_public_refresh_token_duration, + "oAuth2ServerInstallationAccessTokenDuration": @o_auth2_server_installation_access_token_duration, "oAuth2ServerConfidentialPkce": @o_auth2_server_confidential_pkce, "oAuth2ServerVerificationUrl": @o_auth2_server_verification_url, "oAuth2ServerUserCodeLength": @o_auth2_server_user_code_length, diff --git a/lib/appwrite/models/project_auth_method.rb b/lib/appwrite/models/project_auth_method.rb index d94439a4..17cfbbc5 100644 --- a/lib/appwrite/models/project_auth_method.rb +++ b/lib/appwrite/models/project_auth_method.rb @@ -32,9 +32,9 @@ def to_map def validate_id(id) valid_id = [ - Appwrite::Enums::ProjectAuthMethodId::EMAIL-PASSWORD, - Appwrite::Enums::ProjectAuthMethodId::MAGIC-URL, - Appwrite::Enums::ProjectAuthMethodId::EMAIL-OTP, + Appwrite::Enums::ProjectAuthMethodId::EMAIL_PASSWORD, + Appwrite::Enums::ProjectAuthMethodId::MAGIC_URL, + Appwrite::Enums::ProjectAuthMethodId::EMAIL_OTP, Appwrite::Enums::ProjectAuthMethodId::ANONYMOUS, Appwrite::Enums::ProjectAuthMethodId::INVITES, Appwrite::Enums::ProjectAuthMethodId::JWT, diff --git a/lib/appwrite/services/account.rb b/lib/appwrite/services/account.rb index 23087c01..b917162f 100644 --- a/lib/appwrite/services/account.rb +++ b/lib/appwrite/services/account.rb @@ -84,6 +84,215 @@ def create(user_id:, email:, password:, name: nil) end + # Get a list of the OAuth2 consents the current user has given to third-party + # apps. + # + # @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 [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [Oauth2ConsentList] + def list_consents(queries: nil, total: nil) + api_path = '/account/consents' + + 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::Oauth2ConsentList + ) + + end + + # Get an OAuth2 consent the current user has given to a third-party app by + # its unique ID. + # + # @param [String] consent_id Consent unique ID. + # + # @return [Oauth2Consent] + def get_consent(consent_id:) + api_path = '/account/consents/{consentId}' + .gsub('{consentId}', consent_id) + + if consent_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "consentId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Oauth2Consent + ) + + end + + # Delete an OAuth2 consent by its unique ID. All token families issued under + # the consent are revoked, and the app must ask for consent again to regain + # access. + # + # @param [String] consent_id Consent unique ID. + # + # @return [] + def delete_consent(consent_id:) + api_path = '/account/consents/{consentId}' + .gsub('{consentId}', consent_id) + + if consent_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "consentId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + + end + + # Get a list of the token families issued under an OAuth2 consent. Each entry + # represents one authorized device or session; the token secrets themselves + # are never returned. + # + # @param [String] consent_id Consent 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. + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [Oauth2ConsentTokenList] + def list_consent_tokens(consent_id:, queries: nil, total: nil) + api_path = '/account/consents/{consentId}/tokens' + .gsub('{consentId}', consent_id) + + if consent_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "consentId"') + end + + 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::Oauth2ConsentTokenList + ) + + end + + # Get a token family issued under an OAuth2 consent by its unique ID. The + # token secrets themselves are never returned. + # + # @param [String] consent_id Consent unique ID. + # @param [String] token_id Token unique ID. + # + # @return [Oauth2ConsentToken] + def get_consent_token(consent_id:, token_id:) + api_path = '/account/consents/{consentId}/tokens/{tokenId}' + .gsub('{consentId}', consent_id) + .gsub('{tokenId}', token_id) + + if consent_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "consentId"') + end + + if token_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "tokenId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Oauth2ConsentToken + ) + + end + + # Delete a token family issued under an OAuth2 consent by its unique ID. The + # access and refresh tokens of the family stop working immediately; other + # token families and the consent itself are unaffected. + # + # @param [String] consent_id Consent unique ID. + # @param [String] token_id Token unique ID. + # + # @return [] + def delete_consent_token(consent_id:, token_id:) + api_path = '/account/consents/{consentId}/tokens/{tokenId}' + .gsub('{consentId}', consent_id) + .gsub('{tokenId}', token_id) + + if consent_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "consentId"') + end + + if token_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "tokenId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + + end + # Update currently logged in user account email address. After changing user # address, the user confirmation status will get reset. A new confirmation # email is not sent automatically however you can use the send confirmation diff --git a/lib/appwrite/services/apps.rb b/lib/appwrite/services/apps.rb new file mode 100644 index 00000000..bc96e462 --- /dev/null +++ b/lib/appwrite/services/apps.rb @@ -0,0 +1,813 @@ +#frozen_string_literal: true + +module Appwrite + class Apps < Service + + def initialize(client) + @client = client + end + + # List applications. + # + # @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 [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [AppsList] + def list(queries: nil, total: nil) + api_path = '/apps' + + 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::AppsList + ) + + end + + # Create a new application. + # + # @param [String] app_id Application 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 Application name. + # @param [Array] redirect_uris Redirect URIs. Each must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI (e.g. com.example.app:/oauth), and must not contain a fragment. + # @param [String] description Application description shown to users during OAuth2 consent. + # @param [String] client_uri Application homepage URL shown to users during OAuth2 consent. + # @param [String] logo_uri Application logo URL shown to users during OAuth2 consent. + # @param [String] privacy_policy_url Application privacy policy URL shown to users during OAuth2 consent. + # @param [String] terms_url Application terms of service URL shown to users during OAuth2 consent. + # @param [Array] contacts Application support or security contact emails. Maximum of 100 contacts are allowed. + # @param [String] tagline Application tagline shown to users during OAuth2 consent. + # @param [Array] tags Application tags shown to users during OAuth2 consent. Maximum of 100 tags are allowed, each up to 64 characters long. + # @param [Array] images Application image URLs shown to users during OAuth2 consent. Maximum of 100 images are allowed. + # @param [String] support_url Application support URL shown to users during OAuth2 consent. + # @param [String] data_deletion_url Application data deletion URL shown to users during OAuth2 consent. + # @param [Array] post_logout_redirect_uris Post-logout redirect URIs for OpenID Connect RP-Initiated Logout. Each must be an https URL, an http loopback URL, or a private-use scheme URI, and must not contain a fragment. After ending the user session, the logout endpoint only redirects to URIs in this list. + # @param [] enabled Is application enabled? + # @param [String] type OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`. + # @param [] device_flow Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false. + # @param [String] team_id Team unique ID. + # + # @return [App] + def create(app_id:, name:, redirect_uris:, description: nil, client_uri: nil, logo_uri: nil, privacy_policy_url: nil, terms_url: nil, contacts: nil, tagline: nil, tags: nil, images: nil, support_url: nil, data_deletion_url: nil, post_logout_redirect_uris: nil, enabled: nil, type: nil, device_flow: nil, team_id: nil) + api_path = '/apps' + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if redirect_uris.nil? + raise Appwrite::Exception.new('Missing required parameter: "redirectUris"') + end + + api_params = { + appId: app_id, + name: name, + description: description, + clientUri: client_uri, + logoUri: logo_uri, + privacyPolicyUrl: privacy_policy_url, + termsUrl: terms_url, + contacts: contacts, + tagline: tagline, + tags: tags, + images: images, + supportUrl: support_url, + dataDeletionUrl: data_deletion_url, + redirectUris: redirect_uris, + postLogoutRedirectUris: post_logout_redirect_uris, + enabled: enabled, + type: type, + deviceFlow: device_flow, + teamId: team_id, + } + + 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::App + ) + + end + + # List scopes an application can request when installed on a team. + # + # + # @return [AppScopeList] + def list_installation_scopes() + api_path = '/apps/scopes/installations' + + 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::AppScopeList + ) + + end + + # List scopes an application can request during the OAuth2 flow. + # + # + # @return [AppScopeList] + def list_o_auth2_scopes() + api_path = '/apps/scopes/oauth2' + + 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::AppScopeList + ) + + end + + # Get an application by its unique ID. + # + # @param [String] app_id Application unique ID or HTTPS client ID metadata document URL. + # + # @return [App] + def get(app_id:) + api_path = '/apps/{appId}' + .gsub('{appId}', app_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::App + ) + + end + + # Update an application by its unique ID. + # + # @param [String] app_id Application unique ID. + # @param [String] name Application name. + # @param [String] description Application description shown to users during OAuth2 consent. + # @param [String] client_uri Application homepage URL shown to users during OAuth2 consent. + # @param [String] logo_uri Application logo URL shown to users during OAuth2 consent. + # @param [String] privacy_policy_url Application privacy policy URL shown to users during OAuth2 consent. + # @param [String] terms_url Application terms of service URL shown to users during OAuth2 consent. + # @param [Array] contacts Application support or security contact emails. Maximum of 100 contacts are allowed. + # @param [String] tagline Application tagline shown to users during OAuth2 consent. + # @param [Array] tags Application tags shown to users during OAuth2 consent. Maximum of 100 tags are allowed, each up to 64 characters long. + # @param [Array] images Application image URLs shown to users during OAuth2 consent. Maximum of 100 images are allowed. + # @param [String] support_url Application support URL shown to users during OAuth2 consent. + # @param [String] data_deletion_url Application data deletion URL shown to users during OAuth2 consent. + # @param [] enabled Is application enabled? + # @param [Array] redirect_uris Redirect URIs. Each must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI (e.g. com.example.app:/oauth), and must not contain a fragment. + # @param [Array] post_logout_redirect_uris Post-logout redirect URIs for OpenID Connect RP-Initiated Logout. Each must be an https URL, an http loopback URL, or a private-use scheme URI, and must not contain a fragment. After ending the user session, the logout endpoint only redirects to URIs in this list. + # @param [String] type OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`. + # @param [] device_flow Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false. + # @param [Array] installation_scopes Scopes the application requests when installed on a team. Organization-level and project-level scopes only; use the list scopes endpoint with `type=installation` to discover available values. Maximum of 100 scopes are allowed. + # @param [String] installation_redirect_url URL users are redirected to after creating or updating an installation of this application. Must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI, and must not contain a fragment. Leave empty for no redirect. + # + # @return [App] + def update(app_id:, name:, description: nil, client_uri: nil, logo_uri: nil, privacy_policy_url: nil, terms_url: nil, contacts: nil, tagline: nil, tags: nil, images: nil, support_url: nil, data_deletion_url: nil, enabled: nil, redirect_uris: nil, post_logout_redirect_uris: nil, type: nil, device_flow: nil, installation_scopes: nil, installation_redirect_url: nil) + api_path = '/apps/{appId}' + .gsub('{appId}', app_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + api_params = { + name: name, + description: description, + clientUri: client_uri, + logoUri: logo_uri, + privacyPolicyUrl: privacy_policy_url, + termsUrl: terms_url, + contacts: contacts, + tagline: tagline, + tags: tags, + images: images, + supportUrl: support_url, + dataDeletionUrl: data_deletion_url, + enabled: enabled, + redirectUris: redirect_uris, + postLogoutRedirectUris: post_logout_redirect_uris, + type: type, + deviceFlow: device_flow, + installationScopes: installation_scopes, + installationRedirectUrl: installation_redirect_url, + } + + 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::App + ) + + end + + # Delete an application by its unique ID. + # + # @param [String] app_id Application unique ID. + # + # @return [] + def delete(app_id:) + api_path = '/apps/{appId}' + .gsub('{appId}', app_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + + end + + # List installations of an application. Requires an app key sent in the + # `X-Appwrite-Key` header alongside the `X-Appwrite-App` header. + # + # @param [String] app_id Application unique ID. + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [AppInstallationList] + def list_installations(app_id:, queries: nil, total: nil) + api_path = '/apps/{appId}/installations' + .gsub('{appId}', app_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + 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::AppInstallationList + ) + + end + + # Get an installation of an application by its unique ID. Requires an app key + # sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header. + # + # @param [String] app_id Application unique ID. + # @param [String] installation_id Installation unique ID. + # + # @return [AppInstallation] + def get_installation(app_id:, installation_id:) + api_path = '/apps/{appId}/installations/{installationId}' + .gsub('{appId}', app_id) + .gsub('{installationId}', installation_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + if installation_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "installationId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::AppInstallation + ) + + end + + # Create a token for an installation of an application. Requires an app key + # sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header. + # The returned token carries the scopes and authorization details granted to + # the installation, and can be used as an `Authorization: Bearer` header + # everywhere OAuth2 access tokens are accepted. Multiple tokens can be active + # for the same installation at once; each token stays valid until it expires + # or the installation is updated or deleted. + # + # @param [String] app_id Application unique ID. + # @param [String] installation_id Installation unique ID. + # + # @return [Oauth2Token] + def create_installation_token(app_id:, installation_id:) + api_path = '/apps/{appId}/installations/{installationId}/tokens' + .gsub('{appId}', app_id) + .gsub('{installationId}', installation_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + if installation_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "installationId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Oauth2Token + ) + + end + + # List app keys for an application. + # + # @param [String] app_id Application unique ID. + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [AppKeyList] + def list_keys(app_id:, queries: nil, total: nil) + api_path = '/apps/{appId}/keys' + .gsub('{appId}', app_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + 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::AppKeyList + ) + + end + + # Create a new app key for an application. App keys carry no scopes; send one + # in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header to + # list the application's installations and create installation access tokens. + # + # @param [String] app_id Application unique ID. + # + # @return [AppKey] + def create_key(app_id:) + api_path = '/apps/{appId}/keys' + .gsub('{appId}', app_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::AppKey + ) + + end + + # Get an app key by its unique ID. + # + # @param [String] app_id Application unique ID. + # @param [String] key_id App key unique ID. + # + # @return [AppKey] + def get_key(app_id:, key_id:) + api_path = '/apps/{appId}/keys/{keyId}' + .gsub('{appId}', app_id) + .gsub('{keyId}', key_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + if key_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "keyId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::AppKey + ) + + end + + # Delete an app key by its unique ID. + # + # @param [String] app_id Application unique ID. + # @param [String] key_id App key unique ID. + # + # @return [] + def delete_key(app_id:, key_id:) + api_path = '/apps/{appId}/keys/{keyId}' + .gsub('{appId}', app_id) + .gsub('{keyId}', key_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + if key_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "keyId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + + end + + # Update the labels of an application. Labels are read-only for clients; only + # a server SDK using a project API key can set them. Replaces the previous + # labels. + # + # @param [String] app_id Application unique ID. + # @param [Array] labels Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. + # + # @return [App] + def update_labels(app_id:, labels:) + api_path = '/apps/{appId}/labels' + .gsub('{appId}', app_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + if labels.nil? + raise Appwrite::Exception.new('Missing required parameter: "labels"') + end + + api_params = { + labels: labels, + } + + 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::App + ) + + end + + # List client secrets for an application. + # + # @param [String] app_id Application unique ID. + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [AppSecretList] + def list_secrets(app_id:, queries: nil, total: nil) + api_path = '/apps/{appId}/secrets' + .gsub('{appId}', app_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + 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::AppSecretList + ) + + end + + # Create a new client secret for an application. + # + # @param [String] app_id Application unique ID. + # + # @return [AppSecretPlaintext] + def create_secret(app_id:) + api_path = '/apps/{appId}/secrets' + .gsub('{appId}', app_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::AppSecretPlaintext + ) + + end + + # Get an application client secret by its unique ID. + # + # @param [String] app_id Application unique ID. + # @param [String] secret_id Secret unique ID. + # + # @return [AppSecret] + def get_secret(app_id:, secret_id:) + api_path = '/apps/{appId}/secrets/{secretId}' + .gsub('{appId}', app_id) + .gsub('{secretId}', secret_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + if secret_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "secretId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::AppSecret + ) + + end + + # Delete an application client secret by its unique ID. + # + # @param [String] app_id Application unique ID. + # @param [String] secret_id Secret unique ID. + # + # @return [] + def delete_secret(app_id:, secret_id:) + api_path = '/apps/{appId}/secrets/{secretId}' + .gsub('{appId}', app_id) + .gsub('{secretId}', secret_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + if secret_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "secretId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + + end + + # Transfer an application to another team by its unique ID. + # + # @param [String] app_id Application unique ID. + # @param [String] team_id Team ID of the team to transfer application to. + # + # @return [App] + def update_team(app_id:, team_id:) + api_path = '/apps/{appId}/team' + .gsub('{appId}', app_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + + 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::App + ) + + end + + # Revoke all tokens for an application by its unique ID. + # + # @param [String] app_id Application unique ID. + # + # @return [] + def delete_tokens(app_id:) + api_path = '/apps/{appId}/tokens' + .gsub('{appId}', app_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + + end + + end +end diff --git a/lib/appwrite/services/backups.rb b/lib/appwrite/services/backups.rb index 936833da..f923d951 100644 --- a/lib/appwrite/services/backups.rb +++ b/lib/appwrite/services/backups.rb @@ -317,24 +317,38 @@ def delete_policy(policy_id:) # Create and trigger a new restoration for a backup on a project. # - # When restoring a DocumentsDB or VectorsDB database to a new resource, pass - # `newSpecification` to provision the restored database on a different - # specification than the archived one (for example, restoring onto a larger - # or smaller dedicated database). Use `serverless` to restore onto the shared - # pool, or a dedicated specification slug to restore onto a dedicated - # database of that size. The specification must be permitted by the - # organization's plan. `newSpecification` is not supported for - # legacy/TablesDB databases or for bucket restores. + # For a backup of one database, the restoration resolves its destination + # before it is queued. Pass `newResourceId` to restore into that database ID, + # including the archived database ID to overwrite it. When `newResourceId` is + # omitted, a new database ID is generated and returned in `options`. + # + # The restoration migration records the archived database in `resourceId` and + # `resourceType`, and the resolved database in `destinationResourceId` and + # `destinationResourceType`. Database types are stored canonically as + # `database`, `documentsdb`, or `vectorsdb`. Project-wide restorations leave + # these fields empty because they do not have a single source or destination + # database. + # + # To list every migration related to one database, use its canonical type in + # a nested `OR(AND(...), AND(...), AND(...))` across the root, parent, and + # destination relation pairs: `(resourceType, resourceId)`, + # `(parentResourceType, parentResourceId)`, and `(destinationResourceType, + # destinationResourceId)`. Legacy and TablesDB databases use `database`; the + # operational `resourceType` of a table migration is not rewritten to + # `tablesdb`. + # + # When restoring a DocumentsDB or VectorsDB database to a new resource from a + # dedicated source, the restore provisions a fresh dedicated backing database + # at the source database's own specification. # # # @param [String] archive_id Backup archive ID to restore # @param [Array] services Array of services to restore - # @param [String] new_resource_id Unique 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] new_resource_id Destination resource ID. Omit to generate a new ID, or pass the archived resource ID to overwrite it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. # @param [String] new_resource_name Database name. Max length: 128 chars. - # @param [String] new_specification Specification to provision the restored database on, when restoring a DocumentsDB or VectorsDB database to a new resource. Defaults to the archived database's specification. Use `serverless` for the shared pool or a dedicated specification slug. # # @return [BackupRestoration] - def create_restoration(archive_id:, services:, new_resource_id: nil, new_resource_name: nil, new_specification: nil) + def create_restoration(archive_id:, services:, new_resource_id: nil, new_resource_name: nil) api_path = '/backups/restoration' if archive_id.nil? @@ -350,7 +364,6 @@ def create_restoration(archive_id:, services:, new_resource_id: nil, new_resourc services: services, newResourceId: new_resource_id, newResourceName: new_resource_name, - newSpecification: new_specification, } api_headers = { diff --git a/lib/appwrite/services/oauth2.rb b/lib/appwrite/services/oauth2.rb new file mode 100644 index 00000000..0f72a909 --- /dev/null +++ b/lib/appwrite/services/oauth2.rb @@ -0,0 +1,525 @@ +#frozen_string_literal: true + +module Appwrite + class Oauth2 < Service + + def initialize(client) + @client = client + end + + # Approve an OAuth2 grant after the user gives consent. Returns the + # `redirectUrl` the end user should be sent to. The consent screen may + # optionally pass enriched `authorization_details` to record the concrete + # resources the user selected. You can pass Accept header of + # `application/json` to receive a JSON response instead of a redirect. + # + # @param [String] grant_id Grant ID made during authorization, provided to consent screen in URL search params. + # @param [String] authorization_details Enriched `authorization_details` the user consented to, replacing what the client requested. Each entry must use a `type` the project accepts. Optional; omit to keep the originally requested details. + # @param [String] scope Space-separated scopes the user consented to. Must be a subset of the scopes originally requested; identity scopes such as `openid` are always retained. Optional; omit to keep the originally requested scopes. + # + # @return [Oauth2Approve] + def approve(grant_id:, authorization_details: nil, scope: nil) + api_path = '/oauth2/{project_id}/approve' + .gsub('{project_id}', @client.get_config('project')) + + if grant_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "grantId"') + end + + api_params = { + grant_id: grant_id, + authorization_details: authorization_details, + scope: scope, + } + + 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::Oauth2Approve + ) + + end + + # Begin the OAuth2 authorization flow. When called without a session, the + # user is redirected to the consent screen without grant ID. When called with + # a session, the redirect URL includes param for grant ID. You can pass + # Accept header of `application/json` to receive a JSON response instead of a + # redirect. + # + # @param [String] client_id OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + # @param [String] redirect_uri Redirect URI where visitor will be redirected after authorization, whether successful or not. + # @param [String] response_type OAuth2 / OIDC response type. One of `code` (Authorization Code Flow), `id_token` (Implicit Flow, OIDC login only), or `code id_token` (Hybrid Flow). + # @param [String] scope Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`. + # @param [String] state OAuth2 state. You receive this back in the redirect URI. + # @param [String] nonce OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`. + # @param [String] code_challenge PKCE code challenge. Required when OAuth2 app is public. + # @param [String] code_challenge_method PKCE code challenge method. Required when OAuth2 app is public. + # @param [String] prompt OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. + # @param [Integer] max_age OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + # @param [String] authorization_details Rich authorization request. JSON array of objects, each with a `type` and project-defined fields + # @param [String] resource RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + # @param [String] audience Compatibility alias for a single OAuth2 resource indicator URI. + # @param [String] request_uri OAuth2 authorization request handle returned by the pushed authorization request endpoint. + # + # @return [Oauth2Authorize] + def authorize(client_id: nil, redirect_uri: nil, response_type: nil, scope: nil, state: nil, nonce: nil, code_challenge: nil, code_challenge_method: nil, prompt: nil, max_age: nil, authorization_details: nil, resource: nil, audience: nil, request_uri: nil) + api_path = '/oauth2/{project_id}/authorize' + .gsub('{project_id}', @client.get_config('project')) + + api_params = { + client_id: client_id, + redirect_uri: redirect_uri, + response_type: response_type, + scope: scope, + state: state, + nonce: nonce, + code_challenge: code_challenge, + code_challenge_method: code_challenge_method, + prompt: prompt, + max_age: max_age, + authorization_details: authorization_details, + resource: resource, + audience: audience, + request_uri: request_uri, + } + + api_headers = { + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Oauth2Authorize + ) + + end + + # Begin the OAuth2 authorization flow. When called without a session, the + # user is redirected to the consent screen without grant ID. When called with + # a session, the redirect URL includes param for grant ID. You can pass + # Accept header of `application/json` to receive a JSON response instead of a + # redirect. + # + # @param [String] client_id OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + # @param [String] redirect_uri Redirect URI where visitor will be redirected after authorization, whether successful or not. + # @param [String] response_type OAuth2 / OIDC response type. One of `code` (Authorization Code Flow), `id_token` (Implicit Flow, OIDC login only), or `code id_token` (Hybrid Flow). + # @param [String] scope Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`. + # @param [String] state OAuth2 state. You receive this back in the redirect URI. + # @param [String] nonce OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`. + # @param [String] code_challenge PKCE code challenge. Required when OAuth2 app is public. + # @param [String] code_challenge_method PKCE code challenge method. Required when OAuth2 app is public. + # @param [String] prompt OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. + # @param [Integer] max_age OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. + # @param [String] authorization_details Rich authorization request. JSON array of objects, each with a `type` and project-defined fields + # @param [String] resource RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + # @param [String] audience Compatibility alias for a single OAuth2 resource indicator URI. + # @param [String] request_uri OAuth2 authorization request handle returned by the pushed authorization request endpoint. + # + # @return [Oauth2Authorize] + def authorize_post(client_id: nil, redirect_uri: nil, response_type: nil, scope: nil, state: nil, nonce: nil, code_challenge: nil, code_challenge_method: nil, prompt: nil, max_age: nil, authorization_details: nil, resource: nil, audience: nil, request_uri: nil) + api_path = '/oauth2/{project_id}/authorize' + .gsub('{project_id}', @client.get_config('project')) + + api_params = { + client_id: client_id, + redirect_uri: redirect_uri, + response_type: response_type, + scope: scope, + state: state, + nonce: nonce, + code_challenge: code_challenge, + code_challenge_method: code_challenge_method, + prompt: prompt, + max_age: max_age, + authorization_details: authorization_details, + resource: resource, + audience: audience, + request_uri: request_uri, + } + + 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::Oauth2Authorize + ) + + end + + # Start the OAuth2 Device Authorization Grant. Returns the device code, user + # code, verification URL, expiration, and polling interval. + # + # @param [String] client_id OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + # @param [String] scope Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. + # @param [String] authorization_details Rich authorization request. JSON array of objects, each with a `type` and project-defined fields + # @param [String] resource RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + # @param [String] audience Compatibility alias for a single OAuth2 resource indicator URI. + # + # @return [Oauth2DeviceAuthorization] + def create_device_authorization(client_id: nil, scope: nil, authorization_details: nil, resource: nil, audience: nil) + api_path = '/oauth2/{project_id}/device_authorization' + .gsub('{project_id}', @client.get_config('project')) + + api_params = { + client_id: client_id, + scope: scope, + authorization_details: authorization_details, + resource: resource, + audience: audience, + } + + 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::Oauth2DeviceAuthorization + ) + + end + + # Exchange a device flow user code for an OAuth2 grant. The authenticated + # user is bound to the pending grant. Pass the returned grant ID to the get + # grant endpoint to render the consent screen, then to the approve or reject + # endpoint to complete the flow. + # + # @param [String] user_code User code displayed on the device. + # + # @return [Oauth2Grant] + def create_grant(user_code:) + api_path = '/oauth2/{project_id}/grants' + .gsub('{project_id}', @client.get_config('project')) + + if user_code.nil? + raise Appwrite::Exception.new('Missing required parameter: "userCode"') + end + + api_params = { + user_code: user_code, + } + + 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::Oauth2Grant + ) + + end + + # Get an OAuth2 grant by its ID. Used by the consent screen to display the + # details of the authorization the user is being asked to approve. A grant + # can only be read by the user it belongs to, or by server SDK. + # + # @param [String] grant_id Grant ID made during authorization, provided to consent screen in URL search params. + # + # @return [Oauth2Grant] + def get_grant(grant_id:) + api_path = '/oauth2/{project_id}/grants/{grant_id}' + .gsub('{project_id}', @client.get_config('project')) + .gsub('{grant_id}', grant_id) + + if grant_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "grantId"') + end + + api_params = { + } + + api_headers = { + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Oauth2Grant + ) + + 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. + # + # @param [Integer] limit Maximum number of organizations to return. Between 1 and 5000. + # @param [Integer] offset Number of organizations to skip before returning results. Used for pagination. + # @param [String] search Search term to filter your list results. Max length: 256 chars. + # + # @return [Oauth2OrganizationList] + def list_organizations(limit: nil, offset: nil, search: nil) + api_path = '/oauth2/{project_id}/organizations' + .gsub('{project_id}', @client.get_config('project')) + + api_params = { + limit: limit, + offset: offset, + search: search, + } + + api_headers = { + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Oauth2OrganizationList + ) + + end + + # Store an OAuth2 authorization request server-side and receive a short-lived + # request_uri handle for the authorize endpoint. + # + # @param [String] client_id OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + # @param [String] redirect_uri Redirect URI where visitor will be redirected after authorization, whether successful or not. + # @param [String] response_type OAuth2 / OIDC response type. + # @param [String] scope Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`, `phone`. + # @param [String] state OAuth2 state. You receive this back in the redirect URI. + # @param [String] nonce OIDC nonce parameter to prevent replay attacks. Required when response_type includes `id_token`. + # @param [String] code_challenge PKCE code challenge. Required when OAuth2 app is public. + # @param [String] code_challenge_method PKCE code challenge method. Required when OAuth2 app is public. + # @param [String] prompt OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. + # @param [Integer] max_age OIDC max_age parameter for customization of consent screen. + # @param [String] authorization_details Rich authorization request. JSON array of objects, each with a `type` and project-defined fields + # @param [String] resource RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + # @param [String] audience Compatibility alias for a single OAuth2 resource indicator URI. + # + # @return [Oauth2PAR] + def create_par(client_id:, redirect_uri:, response_type:, scope: nil, state: nil, nonce: nil, code_challenge: nil, code_challenge_method: nil, prompt: nil, max_age: nil, authorization_details: nil, resource: nil, audience: nil) + api_path = '/oauth2/{project_id}/par' + .gsub('{project_id}', @client.get_config('project')) + + if client_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "clientId"') + end + + if redirect_uri.nil? + raise Appwrite::Exception.new('Missing required parameter: "redirectUri"') + end + + if response_type.nil? + raise Appwrite::Exception.new('Missing required parameter: "responseType"') + end + + api_params = { + client_id: client_id, + redirect_uri: redirect_uri, + response_type: response_type, + scope: scope, + state: state, + nonce: nonce, + code_challenge: code_challenge, + code_challenge_method: code_challenge_method, + prompt: prompt, + max_age: max_age, + authorization_details: authorization_details, + resource: resource, + audience: audience, + } + + 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::Oauth2PAR + ) + + end + + # List the projects the OAuth2 access token can access. Resolves the token's + # `project` authorization details, expanding the `*` wildcard into the + # concrete set of projects the user can see. + # + # @param [Integer] limit Maximum number of projects to return. Between 1 and 5000. + # @param [Integer] offset Number of projects to skip before returning results. Used for pagination. + # @param [String] search Search term to filter your list results. Max length: 256 chars. + # + # @return [Oauth2ProjectList] + def list_projects(limit: nil, offset: nil, search: nil) + api_path = '/oauth2/{project_id}/projects' + .gsub('{project_id}', @client.get_config('project')) + + api_params = { + limit: limit, + offset: offset, + search: search, + } + + api_headers = { + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Oauth2ProjectList + ) + + end + + # Reject an OAuth2 grant when the user denies consent. Returns the + # `redirectUrl` the end user should be sent to with an `access_denied` error. + # You can pass Accept header of `application/json` to receive a JSON response + # instead of a redirect. + # + # @param [String] grant_id Grant ID made during authorization, provided to consent screen in URL search params. + # + # @return [Oauth2Reject] + def reject(grant_id:) + api_path = '/oauth2/{project_id}/reject' + .gsub('{project_id}', @client.get_config('project')) + + if grant_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "grantId"') + end + + api_params = { + grant_id: grant_id, + } + + 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::Oauth2Reject + ) + + end + + # Revoke an OAuth2 access token or refresh token. + # + # @param [String] token The access or refresh token to revoke. + # @param [String] token_type_hint Type of token to revoke (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. Required for confidential apps; omitted for public apps. + # + # @return [] + def revoke(token:, token_type_hint: nil, client_id: nil, client_secret: nil) + api_path = '/oauth2/{project_id}/revoke' + .gsub('{project_id}', @client.get_config('project')) + + if token.nil? + raise Appwrite::Exception.new('Missing required parameter: "token"') + end + + 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, + ) + + end + + # Exchange an OAuth2 authorization code, refresh token, or device code for + # access and refresh tokens. + # + # @param [String] grant_type OAuth2 grant type. Can be one of: `authorization_code`, `refresh_token`, `urn:ietf:params:oauth:grant-type:device_code`. + # @param [String] code Authorization code to be exchanged for access and refresh tokens. Required for `authorization_code` grant type. + # @param [String] refresh_token Refresh token to be exchanged for a new access and refresh tokens. Required for `refresh_token` grant type. + # @param [String] device_code Device code obtained from the device authorization endpoint. Required for `urn:ietf:params:oauth:grant-type:device_code` grant type. + # @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. Required for confidential apps. + # @param [String] code_verifier PKCE code verifier. Required for public apps. + # @param [String] redirect_uri Redirect URI. Required for `authorization_code` grant type. + # @param [String] resource RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. + # @param [String] audience Compatibility alias for a single OAuth2 resource indicator URI. + # + # @return [Oauth2Token] + def create_token(grant_type:, code: nil, refresh_token: nil, device_code: nil, client_id: nil, client_secret: nil, code_verifier: nil, redirect_uri: nil, resource: nil, audience: nil) + api_path = '/oauth2/{project_id}/token' + .gsub('{project_id}', @client.get_config('project')) + + if grant_type.nil? + raise Appwrite::Exception.new('Missing required parameter: "grantType"') + end + + api_params = { + grant_type: grant_type, + code: code, + refresh_token: refresh_token, + device_code: device_code, + client_id: client_id, + client_secret: client_secret, + code_verifier: code_verifier, + redirect_uri: redirect_uri, + resource: resource, + audience: audience, + } + + 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::Oauth2Token + ) + + end + + end +end diff --git a/lib/appwrite/services/organization.rb b/lib/appwrite/services/organization.rb index 2405ffff..71a003f7 100644 --- a/lib/appwrite/services/organization.rb +++ b/lib/appwrite/services/organization.rb @@ -89,6 +89,174 @@ def delete() end + # List app installations on the organization. Any organization member can + # read installations. + # + # @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 [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [AppInstallationList] + def list_installations(queries: nil, total: nil) + api_path = '/organization/installations' + + 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::AppInstallationList + ) + + end + + # Install an app on the organization. Only organization members with the + # owner role can install apps. The installation is granted the scopes the app + # currently requests. + # + # @param [String] app_id Application unique ID. + # @param [String] authorization_details Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. The Appwrite Console stores authorized project IDs here. + # + # @return [AppInstallation] + def create_installation(app_id:, authorization_details: nil) + api_path = '/organization/installations' + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + api_params = { + appId: app_id, + authorizationDetails: authorization_details, + } + + 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::AppInstallation + ) + + end + + # Get an app installation on the organization by its unique ID. Any + # organization member can read installations. + # + # @param [String] installation_id Installation unique ID. + # + # @return [AppInstallation] + def get_installation(installation_id:) + api_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) + + if installation_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "installationId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::AppInstallation + ) + + end + + # Update an app installation on the organization. Only organization members + # with the owner role can update installations. The installation's granted + # scopes are refreshed to the scopes the app currently requests; previously + # issued installation access tokens are revoked. + # + # @param [String] installation_id Installation unique ID. + # @param [String] authorization_details Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + # + # @return [AppInstallation] + def update_installation(installation_id:, authorization_details: nil) + api_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) + + if installation_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "installationId"') + end + + api_params = { + authorizationDetails: authorization_details, + } + + 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::AppInstallation + ) + + end + + # Uninstall an app from the organization by its installation ID. Only + # organization members with the owner role can remove installations. + # Previously issued installation access tokens are revoked. + # + # @param [String] installation_id Installation unique ID. + # + # @return [] + def delete_installation(installation_id:) + api_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) + + if installation_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "installationId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + + end + # Get a list of all API keys from the current organization. # # @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 diff --git a/lib/appwrite/services/project.rb b/lib/appwrite/services/project.rb index 954ef3bf..d1eee8ff 100644 --- a/lib/appwrite/services/project.rb +++ b/lib/appwrite/services/project.rb @@ -569,6 +569,7 @@ def list_o_auth2_providers(queries: nil, total: nil) # @param [Integer] refresh_token_duration Refresh token duration in seconds for confidential clients (server-side apps that authenticate with a client secret). Leave empty to use default 1 year. # @param [Integer] public_access_token_duration Access token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 1 hour. # @param [Integer] public_refresh_token_duration Refresh token duration in seconds for public clients (SPAs, mobile, and native apps that cannot keep a client secret). Leave empty to use default 30 days. + # @param [Integer] installation_access_token_duration Access token duration in seconds for app installation access tokens. Leave empty to use default 1 hour. # @param [] confidential_pkce When enabled, PKCE is required for confidential clients (server-side flows using client_secret). PKCE is always required for public clients regardless of this setting. # @param [String] verification_url URL to your application page where users enter the device flow user code. Required to enable the Device Authorization Grant. # @param [Integer] user_code_length Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. @@ -577,7 +578,7 @@ def list_o_auth2_providers(queries: nil, total: nil) # @param [Array] default_scopes List of OAuth2 scopes used when an authorization request omits the scope parameter. Every default scope must also be allowed by the OAuth2 server. Maximum of 100 scopes are allowed, each up to 128 characters long. # # @return [Project] - def update_o_auth2_server(enabled:, authorization_url:, scopes: nil, authorization_details_types: nil, access_token_duration: nil, refresh_token_duration: nil, public_access_token_duration: nil, public_refresh_token_duration: nil, confidential_pkce: nil, verification_url: nil, user_code_length: nil, user_code_format: nil, device_code_duration: nil, default_scopes: nil) + def update_o_auth2_server(enabled:, authorization_url:, scopes: nil, authorization_details_types: nil, access_token_duration: nil, refresh_token_duration: nil, public_access_token_duration: nil, public_refresh_token_duration: nil, installation_access_token_duration: nil, confidential_pkce: nil, verification_url: nil, user_code_length: nil, user_code_format: nil, device_code_duration: nil, default_scopes: nil) api_path = '/project/oauth2-server' if enabled.nil? @@ -597,6 +598,7 @@ def update_o_auth2_server(enabled:, authorization_url:, scopes: nil, authorizati refreshTokenDuration: refresh_token_duration, publicAccessTokenDuration: public_access_token_duration, publicRefreshTokenDuration: public_refresh_token_duration, + installationAccessTokenDuration: installation_access_token_duration, confidentialPkce: confidential_pkce, verificationUrl: verification_url, userCodeLength: user_code_length, diff --git a/lib/appwrite/services/sites.rb b/lib/appwrite/services/sites.rb index b077debc..bc93d5b7 100644 --- a/lib/appwrite/services/sites.rb +++ b/lib/appwrite/services/sites.rb @@ -693,9 +693,10 @@ def delete_deployment(site_id:, deployment_id:) # @param [String] site_id Site ID. # @param [String] deployment_id Deployment ID. # @param [DeploymentDownloadType] type Deployment file to download. Can be: "source", "output". + # @param [String] token Presigned source-download token for accessing this deployment without a session (jobs-service). # # @return [] - def get_deployment_download(site_id:, deployment_id:, type: nil) + def get_deployment_download(site_id:, deployment_id:, type: nil, token: nil) api_path = '/sites/{siteId}/deployments/{deploymentId}/download' .gsub('{siteId}', site_id) .gsub('{deploymentId}', deployment_id) @@ -710,6 +711,7 @@ def get_deployment_download(site_id:, deployment_id:, type: nil) api_params = { type: type, + token: token, } api_headers = { diff --git a/lib/appwrite/services/tables_db.rb b/lib/appwrite/services/tables_db.rb index a60395f6..8144d9b7 100644 --- a/lib/appwrite/services/tables_db.rb +++ b/lib/appwrite/services/tables_db.rb @@ -46,9 +46,10 @@ def list(queries: nil, search: nil, total: nil) # @param [String] name Database name. Max length: 128 chars. # @param [] enabled Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. # @param [String] specification Database specification. Defaults to `serverless`, which creates the database on the shared pool. Any other value provisions a dedicated database on that specification. + # @param [Integer] replicas Number of high availability replicas (0-5) for the dedicated database backing this database. Requires a dedicated `specification`; must be 0 for a serverless database. High availability is enabled when greater than 0. # # @return [Database] - def create(database_id:, name:, enabled: nil, specification: nil) + def create(database_id:, name:, enabled: nil, specification: nil, replicas: nil) api_path = '/tablesdb' if database_id.nil? @@ -64,6 +65,7 @@ def create(database_id:, name:, enabled: nil, specification: nil) name: name, enabled: enabled, specification: specification, + replicas: replicas, } api_headers = { @@ -82,6 +84,33 @@ def create(database_id:, name:, enabled: nil, specification: nil) end + # List the dedicated database specifications available on the current plan. + # Each specification reports its resource limits, pricing, and whether it is + # enabled for the organization. + # + # + # @return [DedicatedDatabaseSpecificationList] + def list_specifications() + api_path = '/tablesdb/specifications' + + 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::DedicatedDatabaseSpecificationList + ) + + end + # 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). @@ -305,9 +334,10 @@ def get(database_id:) # @param [String] database_id Database ID. # @param [String] name Database name. Max length: 128 chars. # @param [] enabled Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + # @param [Integer] replicas Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. # # @return [Database] - def update(database_id:, name: nil, enabled: nil) + def update(database_id:, name: nil, enabled: nil, replicas: nil) api_path = '/tablesdb/{databaseId}' .gsub('{databaseId}', database_id) @@ -318,6 +348,7 @@ def update(database_id:, name: nil, enabled: nil) api_params = { name: name, enabled: enabled, + replicas: replicas, } api_headers = { @@ -367,6 +398,107 @@ def delete(database_id:) end + # Trigger a manual failover for a dedicated database with high availability + # enabled. Promotes a replica to primary. The failover runs asynchronously; + # poll the database document for status updates. + # + # @param [String] database_id Database ID. + # @param [String] target_replica_id Target replica ID to promote. If not specified, the healthiest replica is selected. + # + # @return [DedicatedDatabase] + def create_failover(database_id:, target_replica_id: nil) + api_path = '/tablesdb/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + api_params = { + targetReplicaId: target_replica_id, + } + + 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::DedicatedDatabase + ) + + end + + # Get high availability status for a dedicated database. Returns replica + # statuses, replication lag, and sync mode. + # + # @param [String] database_id Database ID. + # + # @return [DedicatedDatabaseReplicas] + def get_replicas(database_id:) + api_path = '/tablesdb/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DedicatedDatabaseReplicas + ) + + end + + # Get real-time health and status information for a dedicated database. + # Returns health status, readiness, uptime, connection info, replica status, + # and volume information. + # + # @param [String] database_id Database ID. + # + # @return [DatabaseStatus] + def get_status(database_id:) + api_path = '/tablesdb/{databaseId}/status' + .gsub('{databaseId}', database_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DatabaseStatus + ) + + end + # Get a list of all tables that belong to the provided databaseId. You can # use the search parameter to filter your results. # diff --git a/lib/appwrite/services/teams.rb b/lib/appwrite/services/teams.rb index c41f7fa4..3ae89b4d 100644 --- a/lib/appwrite/services/teams.rb +++ b/lib/appwrite/services/teams.rb @@ -181,6 +181,204 @@ def delete(team_id:) end + # List app installations on a team. Any team member can read installations. + # + # @param [String] team_id Team 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. + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [AppInstallationList] + def list_installations(team_id:, queries: nil, total: nil) + api_path = '/teams/{teamId}/installations' + .gsub('{teamId}', team_id) + + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + + 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::AppInstallationList + ) + + end + + # Install an app on a team. When authenticated as a user, only team members + # with the owner role can install apps. Requests using an API key or in admin + # mode can install apps on any team. The installation is granted the scopes + # the app currently requests. + # + # @param [String] team_id Team ID. + # @param [String] app_id Application unique ID. + # @param [String] authorization_details Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. The Appwrite Console stores authorized project IDs here. + # + # @return [AppInstallation] + def create_installation(team_id:, app_id:, authorization_details: nil) + api_path = '/teams/{teamId}/installations' + .gsub('{teamId}', team_id) + + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + api_params = { + appId: app_id, + authorizationDetails: authorization_details, + } + + 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::AppInstallation + ) + + end + + # Get an app installation on a team by its unique ID. Any team member can + # read installations. + # + # @param [String] team_id Team ID. + # @param [String] installation_id Installation unique ID. + # + # @return [AppInstallation] + def get_installation(team_id:, installation_id:) + api_path = '/teams/{teamId}/installations/{installationId}' + .gsub('{teamId}', team_id) + .gsub('{installationId}', installation_id) + + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + + if installation_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "installationId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::AppInstallation + ) + + end + + # Update an app installation on a team. Only team members with the owner role + # can update installations. The installation's granted scopes are refreshed + # to the scopes the app currently requests; previously issued installation + # access tokens are revoked. + # + # @param [String] team_id Team ID. + # @param [String] installation_id Installation unique ID. + # @param [String] authorization_details Authorization details granted to the installation as a JSON array of objects, each with a `type` and app-defined fields. Omit to keep the current value. + # + # @return [AppInstallation] + def update_installation(team_id:, installation_id:, authorization_details: nil) + api_path = '/teams/{teamId}/installations/{installationId}' + .gsub('{teamId}', team_id) + .gsub('{installationId}', installation_id) + + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + + if installation_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "installationId"') + end + + api_params = { + authorizationDetails: authorization_details, + } + + 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::AppInstallation + ) + + end + + # Uninstall an app from a team by its installation ID. Only team members with + # the owner role can remove installations. Previously issued installation + # access tokens are revoked. + # + # @param [String] team_id Team ID. + # @param [String] installation_id Installation unique ID. + # + # @return [] + def delete_installation(team_id:, installation_id:) + api_path = '/teams/{teamId}/installations/{installationId}' + .gsub('{teamId}', team_id) + .gsub('{installationId}', installation_id) + + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + + if installation_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "installationId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + + end + # Use this endpoint to list a team's members using the team's ID. All team # members have read access to this endpoint. Hide sensitive attributes from # the response by toggling membership privacy in the Console.