From 5b5dd69cdbfb79adcdc2dffe2108540d2e858c03 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 14 Oct 2026 16:37:17 +0100 Subject: [PATCH 1/4] feat: SDK update for the 2.5.x majors --- CHANGELOG.md | 14 + README.md | 4 +- appwrite.gemspec | 2 +- docs/examples/account/list-logs.md | 17 - docs/examples/avatars/get-screenshot.md | 3 +- docs/examples/databases/create-documents.md | 11 +- docs/examples/databases/create-index.md | 2 +- docs/examples/databases/delete-documents.md | 2 +- docs/examples/databases/upsert-documents.md | 11 +- docs/examples/documentsdb/create-documents.md | 11 +- docs/examples/documentsdb/create-index.md | 2 +- docs/examples/documentsdb/delete-documents.md | 2 +- docs/examples/documentsdb/upsert-documents.md | 11 +- docs/examples/domains/get-price.md | 2 +- docs/examples/domains/list-prices.md | 2 +- .../embeddings/create-text-embeddings.md | 2 +- docs/examples/graphql/mutation.md | 4 +- docs/examples/graphql/query.md | 4 +- .../messaging/create-twilio-provider.md | 2 +- docs/examples/mongo/update.md | 2 +- docs/examples/mysql/update.md | 2 +- docs/examples/oauth2/approve.md | 2 +- docs/examples/oauth2/authorize-post.md | 4 +- docs/examples/oauth2/authorize.md | 4 +- .../oauth2/create-device-authorization.md | 4 +- docs/examples/oauth2/create-grant.md | 2 +- docs/examples/oauth2/create-par.md | 4 +- docs/examples/oauth2/create-token.md | 4 +- docs/examples/oauth2/get-grant.md | 2 +- docs/examples/oauth2/list-organizations.md | 2 +- docs/examples/oauth2/list-projects.md | 2 +- docs/examples/oauth2/reject.md | 2 +- docs/examples/oauth2/revoke.md | 2 +- docs/examples/organization/create-key.md | 20 - docs/examples/organization/delete-key.md | 16 - docs/examples/organization/get-key.md | 16 - docs/examples/organization/list-keys.md | 17 - docs/examples/organization/update-key.md | 20 - docs/examples/postgresql/update.md | 2 +- docs/examples/project/create-ephemeral-key.md | 2 +- docs/examples/project/create-smtp-test.md | 2 +- docs/examples/project/update-key.md | 2 +- docs/examples/project/update-labels.md | 2 +- .../examples/project/update-o-auth-2-kakao.md | 4 +- docs/examples/storage/get-file-preview.md | 2 +- docs/examples/tablesdb/create-index.md | 2 +- docs/examples/tablesdb/create-rows.md | 11 +- docs/examples/tablesdb/delete-rows.md | 2 +- docs/examples/tablesdb/upsert-rows.md | 11 +- docs/examples/teams/create-membership.md | 2 +- docs/examples/teams/update-membership.md | 2 +- docs/examples/users/list-logs.md | 18 - docs/examples/users/update-labels.md | 2 +- docs/examples/vectorsdb/create-collection.md | 2 +- docs/examples/vectorsdb/create-documents.md | 15 +- docs/examples/vectorsdb/create-index.md | 2 +- docs/examples/vectorsdb/create-operations.md | 10 +- docs/examples/vectorsdb/delete-documents.md | 2 +- docs/examples/vectorsdb/update-collection.md | 2 +- docs/examples/vectorsdb/upsert-documents.md | 15 +- docs/examples/webhooks/create.md | 2 +- docs/examples/webhooks/update.md | 2 +- lib/appwrite.rb | 13 +- lib/appwrite/client.rb | 32 +- lib/appwrite/enums/billing_plan_group.rb | 1 - lib/appwrite/enums/organization_key_scopes.rb | 22 - lib/appwrite/models/activity_event.rb | 1 + lib/appwrite/models/activity_event_list.rb | 1 + lib/appwrite/models/additional_resource.rb | 1 + lib/appwrite/models/algo_argon2.rb | 1 + lib/appwrite/models/algo_bcrypt.rb | 1 + lib/appwrite/models/algo_md5.rb | 1 + lib/appwrite/models/algo_phpass.rb | 1 + lib/appwrite/models/algo_scrypt.rb | 1 + lib/appwrite/models/algo_scrypt_modified.rb | 1 + lib/appwrite/models/algo_sha.rb | 1 + lib/appwrite/models/app.rb | 1 + lib/appwrite/models/app_installation.rb | 1 + lib/appwrite/models/app_installation_list.rb | 1 + lib/appwrite/models/app_key.rb | 1 + lib/appwrite/models/app_key_list.rb | 1 + lib/appwrite/models/app_scope.rb | 1 + lib/appwrite/models/app_scope_list.rb | 1 + lib/appwrite/models/app_secret.rb | 1 + lib/appwrite/models/app_secret_list.rb | 1 + lib/appwrite/models/app_secret_plaintext.rb | 1 + lib/appwrite/models/apps_list.rb | 1 + lib/appwrite/models/attribute_bigint.rb | 1 + lib/appwrite/models/attribute_boolean.rb | 1 + lib/appwrite/models/attribute_datetime.rb | 1 + lib/appwrite/models/attribute_email.rb | 1 + lib/appwrite/models/attribute_enum.rb | 1 + lib/appwrite/models/attribute_float.rb | 1 + lib/appwrite/models/attribute_integer.rb | 1 + lib/appwrite/models/attribute_ip.rb | 1 + lib/appwrite/models/attribute_line.rb | 1 + lib/appwrite/models/attribute_list.rb | 1 + lib/appwrite/models/attribute_longtext.rb | 1 + lib/appwrite/models/attribute_mediumtext.rb | 1 + lib/appwrite/models/attribute_object.rb | 1 + lib/appwrite/models/attribute_point.rb | 1 + lib/appwrite/models/attribute_polygon.rb | 1 + lib/appwrite/models/attribute_relationship.rb | 1 + lib/appwrite/models/attribute_string.rb | 1 + lib/appwrite/models/attribute_text.rb | 1 + lib/appwrite/models/attribute_url.rb | 1 + lib/appwrite/models/attribute_varchar.rb | 1 + lib/appwrite/models/attribute_vector.rb | 1 + lib/appwrite/models/backup_archive.rb | 1 + lib/appwrite/models/backup_archive_list.rb | 1 + lib/appwrite/models/backup_policy.rb | 1 + lib/appwrite/models/backup_policy_list.rb | 1 + lib/appwrite/models/backup_restoration.rb | 1 + .../models/backup_restoration_list.rb | 1 + lib/appwrite/models/billing_limits.rb | 16 +- lib/appwrite/models/billing_plan.rb | 20 +- .../models/billing_plan_addon_details.rb | 1 + .../billing_plan_dedicated_database_limits.rb | 38 +- lib/appwrite/models/billing_plan_limits.rb | 4 +- .../models/billing_plan_supported_addons.rb | 1 + lib/appwrite/models/block.rb | 37 +- lib/appwrite/models/bucket.rb | 1 + lib/appwrite/models/bucket_list.rb | 1 + lib/appwrite/models/collection.rb | 1 + lib/appwrite/models/collection_list.rb | 1 + lib/appwrite/models/column_bigint.rb | 1 + lib/appwrite/models/column_boolean.rb | 1 + lib/appwrite/models/column_datetime.rb | 1 + lib/appwrite/models/column_email.rb | 1 + lib/appwrite/models/column_enum.rb | 1 + lib/appwrite/models/column_float.rb | 1 + lib/appwrite/models/column_index.rb | 3 +- lib/appwrite/models/column_index_list.rb | 1 + lib/appwrite/models/column_integer.rb | 1 + lib/appwrite/models/column_ip.rb | 1 + lib/appwrite/models/column_line.rb | 1 + lib/appwrite/models/column_list.rb | 1 + lib/appwrite/models/column_longtext.rb | 1 + lib/appwrite/models/column_mediumtext.rb | 1 + lib/appwrite/models/column_point.rb | 1 + lib/appwrite/models/column_polygon.rb | 1 + lib/appwrite/models/column_relationship.rb | 1 + lib/appwrite/models/column_string.rb | 1 + lib/appwrite/models/column_text.rb | 1 + lib/appwrite/models/column_url.rb | 1 + lib/appwrite/models/column_varchar.rb | 1 + lib/appwrite/models/continent.rb | 1 + lib/appwrite/models/continent_list.rb | 1 + lib/appwrite/models/country.rb | 1 + lib/appwrite/models/country_list.rb | 1 + lib/appwrite/models/currency.rb | 1 + lib/appwrite/models/currency_list.rb | 1 + lib/appwrite/models/database.rb | 1 + lib/appwrite/models/database_list.rb | 1 + lib/appwrite/models/database_migration.rb | 1 + .../models/database_migration_list.rb | 1 + lib/appwrite/models/database_status.rb | 5 +- .../models/database_status_connections.rb | 1 + .../models/database_status_replica.rb | 1 + lib/appwrite/models/database_status_volume.rb | 1 + lib/appwrite/models/dedicated_database.rb | 1 + .../models/dedicated_database_backup.rb | 1 + .../models/dedicated_database_backup_list.rb | 1 + .../dedicated_database_backup_storage.rb | 1 + .../models/dedicated_database_branch.rb | 1 + .../models/dedicated_database_branch_list.rb | 1 + .../models/dedicated_database_execution.rb | 1 + .../dedicated_database_execution_column.rb | 1 + .../models/dedicated_database_extensions.rb | 1 + .../models/dedicated_database_list.rb | 1 + .../models/dedicated_database_member.rb | 1 + .../models/dedicated_database_operation.rb | 1 + .../dedicated_database_operation_list.rb | 1 + .../models/dedicated_database_pitr_windows.rb | 1 + .../models/dedicated_database_pooler.rb | 1 + .../models/dedicated_database_replicas.rb | 1 + .../models/dedicated_database_restoration.rb | 1 + .../dedicated_database_restoration_list.rb | 1 + .../dedicated_database_specification.rb | 1 + .../dedicated_database_specification_list.rb | 12 +- ...edicated_database_specification_pricing.rb | 42 - lib/appwrite/models/deployment.rb | 1 + lib/appwrite/models/deployment_list.rb | 1 + lib/appwrite/models/dev_key.rb | 62 - lib/appwrite/models/document.rb | 1 + lib/appwrite/models/document_list.rb | 1 + lib/appwrite/models/email_template.rb | 1 + lib/appwrite/models/email_template_list.rb | 1 + lib/appwrite/models/embedding.rb | 1 + lib/appwrite/models/embedding_list.rb | 1 + lib/appwrite/models/ephemeral_key.rb | 1 + lib/appwrite/models/execution.rb | 1 + lib/appwrite/models/execution_list.rb | 1 + lib/appwrite/models/file.rb | 1 + lib/appwrite/models/file_list.rb | 1 + lib/appwrite/models/framework.rb | 1 + lib/appwrite/models/framework_adapter.rb | 1 + lib/appwrite/models/framework_list.rb | 1 + lib/appwrite/models/function.rb | 3 +- lib/appwrite/models/function_list.rb | 1 + lib/appwrite/models/headers.rb | 1 + lib/appwrite/models/identity.rb | 1 + lib/appwrite/models/identity_list.rb | 1 + lib/appwrite/models/index.rb | 3 +- lib/appwrite/models/index_list.rb | 1 + lib/appwrite/models/insight.rb | 1 + lib/appwrite/models/insight_cta.rb | 1 + lib/appwrite/models/insight_list.rb | 1 + lib/appwrite/models/jwt.rb | 1 + lib/appwrite/models/key.rb | 1 + lib/appwrite/models/key_list.rb | 1 + lib/appwrite/models/language.rb | 1 + lib/appwrite/models/language_list.rb | 1 + lib/appwrite/models/locale.rb | 1 + lib/appwrite/models/locale_code.rb | 1 + lib/appwrite/models/locale_code_list.rb | 1 + lib/appwrite/models/log.rb | 132 -- lib/appwrite/models/log_list.rb | 32 - lib/appwrite/models/membership.rb | 1 + lib/appwrite/models/membership_list.rb | 1 + lib/appwrite/models/message.rb | 1 + lib/appwrite/models/message_list.rb | 1 + lib/appwrite/models/mfa_challenge.rb | 1 + lib/appwrite/models/mfa_challenge_secret.rb | 1 + lib/appwrite/models/mfa_factors.rb | 1 + lib/appwrite/models/mfa_recovery_codes.rb | 1 + lib/appwrite/models/mfa_type.rb | 1 + lib/appwrite/models/mock_number.rb | 1 + lib/appwrite/models/mock_number_list.rb | 1 + lib/appwrite/models/o_auth2_amazon.rb | 1 + lib/appwrite/models/o_auth2_apple.rb | 1 + lib/appwrite/models/o_auth2_appwrite.rb | 1 + lib/appwrite/models/o_auth2_auth0.rb | 3 +- lib/appwrite/models/o_auth2_authentik.rb | 1 + lib/appwrite/models/o_auth2_autodesk.rb | 1 + lib/appwrite/models/o_auth2_bitbucket.rb | 1 + lib/appwrite/models/o_auth2_bitly.rb | 1 + lib/appwrite/models/o_auth2_box.rb | 1 + lib/appwrite/models/o_auth2_cloudflare.rb | 1 + lib/appwrite/models/o_auth2_dailymotion.rb | 1 + lib/appwrite/models/o_auth2_discord.rb | 3 +- lib/appwrite/models/o_auth2_disqus.rb | 1 + lib/appwrite/models/o_auth2_dropbox.rb | 1 + lib/appwrite/models/o_auth2_etsy.rb | 1 + lib/appwrite/models/o_auth2_facebook.rb | 1 + lib/appwrite/models/o_auth2_figma.rb | 1 + lib/appwrite/models/o_auth2_fusion_auth.rb | 1 + lib/appwrite/models/o_auth2_github.rb | 3 +- lib/appwrite/models/o_auth2_gitlab.rb | 1 + lib/appwrite/models/o_auth2_google.rb | 1 + lib/appwrite/models/o_auth2_hugging_face.rb | 1 + lib/appwrite/models/o_auth2_keycloak.rb | 1 + lib/appwrite/models/o_auth2_kick.rb | 1 + lib/appwrite/models/o_auth2_linkedin.rb | 1 + lib/appwrite/models/o_auth2_microsoft.rb | 3 +- lib/appwrite/models/o_auth2_notion.rb | 1 + lib/appwrite/models/o_auth2_oidc.rb | 11 +- lib/appwrite/models/o_auth2_okta.rb | 3 +- lib/appwrite/models/o_auth2_paypal.rb | 1 + lib/appwrite/models/o_auth2_podio.rb | 1 + lib/appwrite/models/o_auth2_provider_list.rb | 1 + lib/appwrite/models/o_auth2_resend.rb | 1 + lib/appwrite/models/o_auth2_salesforce.rb | 3 +- lib/appwrite/models/o_auth2_slack.rb | 1 + lib/appwrite/models/o_auth2_spotify.rb | 1 + lib/appwrite/models/o_auth2_stripe.rb | 1 + lib/appwrite/models/o_auth2_tradeshift.rb | 1 + lib/appwrite/models/o_auth2_twitch.rb | 1 + lib/appwrite/models/o_auth2_word_press.rb | 1 + lib/appwrite/models/o_auth2_x.rb | 1 + lib/appwrite/models/o_auth2_yahoo.rb | 1 + lib/appwrite/models/o_auth2_yandex.rb | 1 + lib/appwrite/models/o_auth2_zoho.rb | 3 +- lib/appwrite/models/o_auth2_zoom.rb | 1 + lib/appwrite/models/oauth2_approve.rb | 1 + lib/appwrite/models/oauth2_authorize.rb | 1 + lib/appwrite/models/oauth2_consent.rb | 1 + lib/appwrite/models/oauth2_consent_list.rb | 1 + lib/appwrite/models/oauth2_consent_token.rb | 1 + .../models/oauth2_consent_token_list.rb | 1 + .../models/oauth2_device_authorization.rb | 1 + lib/appwrite/models/oauth2_grant.rb | 1 + lib/appwrite/models/oauth2_organization.rb | 1 + .../models/oauth2_organization_list.rb | 1 + lib/appwrite/models/oauth2_par.rb | 1 + lib/appwrite/models/oauth2_project.rb | 1 + lib/appwrite/models/oauth2_project_list.rb | 1 + lib/appwrite/models/oauth2_reject.rb | 1 + lib/appwrite/models/oauth2_token.rb | 1 + lib/appwrite/models/organization.rb | 1 + lib/appwrite/models/passkey.rb | 1 + lib/appwrite/models/passkey_challenge.rb | 1 + lib/appwrite/models/passkey_list.rb | 1 + lib/appwrite/models/phone.rb | 1 + lib/appwrite/models/phone_list.rb | 1 + lib/appwrite/models/platform_android.rb | 1 + lib/appwrite/models/platform_apple.rb | 1 + lib/appwrite/models/platform_linux.rb | 1 + lib/appwrite/models/platform_list.rb | 1 + lib/appwrite/models/platform_web.rb | 1 + lib/appwrite/models/platform_windows.rb | 1 + .../models/policy_deny_aliased_email.rb | 1 + .../models/policy_deny_corporate_email.rb | 1 + .../models/policy_deny_disposable_email.rb | 1 + lib/appwrite/models/policy_deny_free_email.rb | 1 + lib/appwrite/models/policy_list.rb | 1 + .../models/policy_membership_privacy.rb | 1 + lib/appwrite/models/policy_mfa_factors.rb | 1 + lib/appwrite/models/policy_passkey.rb | 1 + .../models/policy_password_dictionary.rb | 1 + .../models/policy_password_history.rb | 1 + .../models/policy_password_personal_data.rb | 1 + .../models/policy_password_strength.rb | 1 + lib/appwrite/models/policy_session_alert.rb | 1 + .../models/policy_session_duration.rb | 1 + .../models/policy_session_invalidation.rb | 1 + lib/appwrite/models/policy_session_limit.rb | 1 + lib/appwrite/models/policy_user_limit.rb | 1 + lib/appwrite/models/postgres_extension.rb | 1 + lib/appwrite/models/presence.rb | 1 + lib/appwrite/models/presence_list.rb | 1 + lib/appwrite/models/program.rb | 1 + lib/appwrite/models/project.rb | 30 +- lib/appwrite/models/project_auth_method.rb | 1 + lib/appwrite/models/project_list.rb | 1 + lib/appwrite/models/project_protocol.rb | 1 + lib/appwrite/models/project_service.rb | 1 + lib/appwrite/models/provider.rb | 3 +- lib/appwrite/models/provider_list.rb | 1 + lib/appwrite/models/proxy_invalidation.rb | 1 + lib/appwrite/models/proxy_rule.rb | 1 + lib/appwrite/models/proxy_rule_list.rb | 1 + lib/appwrite/models/report.rb | 1 + lib/appwrite/models/report_list.rb | 1 + lib/appwrite/models/resource_token.rb | 1 + lib/appwrite/models/resource_token_list.rb | 1 + lib/appwrite/models/row.rb | 1 + lib/appwrite/models/row_list.rb | 1 + lib/appwrite/models/runtime.rb | 1 + lib/appwrite/models/runtime_list.rb | 1 + lib/appwrite/models/session.rb | 1 + lib/appwrite/models/session_list.rb | 1 + lib/appwrite/models/site.rb | 1 + lib/appwrite/models/site_list.rb | 1 + lib/appwrite/models/specification.rb | 1 + lib/appwrite/models/specification_list.rb | 1 + lib/appwrite/models/subscriber.rb | 1 + lib/appwrite/models/subscriber_list.rb | 1 + lib/appwrite/models/table.rb | 1 + lib/appwrite/models/table_list.rb | 1 + lib/appwrite/models/target.rb | 1 + lib/appwrite/models/target_list.rb | 1 + lib/appwrite/models/team.rb | 1 + lib/appwrite/models/team_list.rb | 1 + lib/appwrite/models/token.rb | 1 + lib/appwrite/models/token_secret.rb | 1 + lib/appwrite/models/topic.rb | 1 + lib/appwrite/models/topic_list.rb | 1 + lib/appwrite/models/transaction.rb | 1 + lib/appwrite/models/transaction_list.rb | 1 + lib/appwrite/models/usage_billing_plan.rb | 32 +- lib/appwrite/models/user.rb | 1 + lib/appwrite/models/user_list.rb | 1 + lib/appwrite/models/variable.rb | 1 + lib/appwrite/models/variable_list.rb | 1 + lib/appwrite/models/vectorsdb_collection.rb | 1 + .../models/vectorsdb_collection_list.rb | 1 + lib/appwrite/models/webhook.rb | 1 + lib/appwrite/models/webhook_list.rb | 1 + lib/appwrite/services/account.rb | 244 ++-- lib/appwrite/services/activities.rb | 8 +- lib/appwrite/services/advisor.rb | 37 +- lib/appwrite/services/apps.rb | 178 +-- lib/appwrite/services/avatars.rb | 42 +- lib/appwrite/services/backups.rb | 60 +- lib/appwrite/services/databases.rb | 946 +++++++------- lib/appwrite/services/documents_db.rb | 385 +++--- lib/appwrite/services/domains.rb | 110 +- lib/appwrite/services/embeddings.rb | 4 +- lib/appwrite/services/functions.rb | 221 ++-- lib/appwrite/services/graphql.rb | 8 +- lib/appwrite/services/messaging.rb | 308 ++--- lib/appwrite/services/mongo.rb | 262 ++-- lib/appwrite/services/mysql.rb | 286 ++-- lib/appwrite/services/oauth2.rb | 54 +- lib/appwrite/services/organization.rb | 301 +---- lib/appwrite/services/postgresql.rb | 314 ++--- lib/appwrite/services/presences.rb | 33 +- lib/appwrite/services/project.rb | 291 +++-- lib/appwrite/services/proxy.rb | 47 +- lib/appwrite/services/sites.rb | 212 +-- lib/appwrite/services/storage.rb | 121 +- lib/appwrite/services/tables_db.rb | 1152 +++++++++-------- lib/appwrite/services/teams.rb | 164 +-- lib/appwrite/services/tokens.rb | 49 +- lib/appwrite/services/users.rb | 369 +++--- lib/appwrite/services/vectors_db.rb | 357 ++--- lib/appwrite/services/waf.rb | 14 +- lib/appwrite/services/webhooks.rb | 45 +- 399 files changed, 3831 insertions(+), 3996 deletions(-) delete mode 100644 docs/examples/account/list-logs.md delete mode 100644 docs/examples/organization/create-key.md delete mode 100644 docs/examples/organization/delete-key.md delete mode 100644 docs/examples/organization/get-key.md delete mode 100644 docs/examples/organization/list-keys.md delete mode 100644 docs/examples/organization/update-key.md delete mode 100644 docs/examples/users/list-logs.md delete mode 100644 lib/appwrite/enums/organization_key_scopes.rb delete mode 100644 lib/appwrite/models/dedicated_database_specification_pricing.rb delete mode 100644 lib/appwrite/models/dev_key.rb delete mode 100644 lib/appwrite/models/log.rb delete mode 100644 lib/appwrite/models/log_list.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index cdc8ff1a..36327225 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Change Log +## 29.0.0 + +* Breaking: requests send `X-Appwrite-Response-Format: 2.5.0`; responses follow the 2.5 shapes +* Breaking: removed `account.list_logs`, `users.list_logs` and the `Log`/`LogList` models +* Breaking: removed `organization.create_key`, `list_keys`, `update_key` and `OrganizationKeyScopes`; use project keys +* Breaking: removed `Client#set_dev_key`, the `DevKey` model and `Project#dev_keys` +* Breaking: removed `BillingPlanGroup::STARTER` +* Breaking: removed `DedicatedDatabaseSpecificationPricing` and `DedicatedDatabaseSpecificationList#pricing` +* Breaking: removed `Block` fields `reason`, `project_name`, `region`, `organization_name`, `organization_id` and `billing_plan` +* Breaking: OAuth2 `resource:` params now take an array +* Breaking: `BackupRestoration#options` is now a hash +* Breaking: some response fields became optional, such as `BillingPlan#usage` and `DedicatedDatabase#engine` +* Updated: missing response fields fall back to their documented defaults in more models + ## 28.4.0 * Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones diff --git a/README.md b/README.md index ebd62348..108c7722 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Ruby SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.0.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 1.9.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-ruby/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-ruby/releases) when APIs differ. Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Ruby SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/appwrite.gemspec b/appwrite.gemspec index 7fe70b3b..4054abff 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '28.4.0' + spec.version = '29.0.0' spec.license = 'BSD-3-Clause' spec.summary = 'Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API' spec.author = 'Appwrite Team' diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md deleted file mode 100644 index 171d4306..00000000 --- a/docs/examples/account/list-logs.md +++ /dev/null @@ -1,17 +0,0 @@ -```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_logs( - queries: [], # optional - total: false # optional -) -``` diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 742c87fd..331e4292 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -14,8 +14,7 @@ avatars = Avatars.new(client) result = avatars.get_screenshot( url: 'https://example.com', headers: { - "Authorization" => "Bearer token123", - "X-Custom-Header" => "value" + "Accept-Language" => "en-US,en;q=0.9" }, # optional viewport_width: 1920, # optional viewport_height: 1080, # optional diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 60acd19f..25b4cbd9 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -13,7 +13,16 @@ databases = Databases.new(client) result = databases.create_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index e3e9238a..924f512f 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -16,7 +16,7 @@ result = databases.create_index( collection_id: '', key: '', type: DatabasesIndexType::KEY, - attributes: [], + attributes: ["username"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index c9309bd9..29ea3583 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -13,7 +13,7 @@ databases = Databases.new(client) result = databases.delete_documents( database_id: '', collection_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 49432e01..6cf394c5 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -13,7 +13,16 @@ databases = Databases.new(client) result = databases.upsert_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index 1277f4ac..b895f1c5 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -13,7 +13,16 @@ documents_db = DocumentsDB.new(client) result = documents_db.create_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md index d1891f9a..a8c4e35f 100644 --- a/docs/examples/documentsdb/create-index.md +++ b/docs/examples/documentsdb/create-index.md @@ -16,7 +16,7 @@ result = documents_db.create_index( collection_id: '', key: '', type: DocumentsDBIndexType::KEY, - attributes: [], + attributes: ["username"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md index cd628c75..b1ea2032 100644 --- a/docs/examples/documentsdb/delete-documents.md +++ b/docs/examples/documentsdb/delete-documents.md @@ -13,7 +13,7 @@ documents_db = DocumentsDB.new(client) result = documents_db.delete_documents( database_id: '', collection_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md index f7f05970..0876756c 100644 --- a/docs/examples/documentsdb/upsert-documents.md +++ b/docs/examples/documentsdb/upsert-documents.md @@ -13,7 +13,16 @@ documents_db = DocumentsDB.new(client) result = documents_db.upsert_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/domains/get-price.md b/docs/examples/domains/get-price.md index 4658fab8..7727397c 100644 --- a/docs/examples/domains/get-price.md +++ b/docs/examples/domains/get-price.md @@ -13,7 +13,7 @@ domains = Domains.new(client) result = domains.get_price( domain: 'example.com', - period_years: nil, # optional + period_years: null, # optional registration_type: DomainRegistrationType::NEW # optional ) ``` diff --git a/docs/examples/domains/list-prices.md b/docs/examples/domains/list-prices.md index a99450dc..14ced00c 100644 --- a/docs/examples/domains/list-prices.md +++ b/docs/examples/domains/list-prices.md @@ -13,7 +13,7 @@ domains = Domains.new(client) result = domains.list_prices( domains: [], - period_years: nil, # optional + period_years: null, # optional registration_type: DomainRegistrationType::NEW # optional ) ``` diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index facbe573..fecbe281 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -12,7 +12,7 @@ client = Client.new embeddings = Embeddings.new(client) result = embeddings.create_text_embeddings( - texts: [], + texts: ["Appwrite helps developers build applications.", "Find documents with semantic search."], model: EmbeddingModel::NOMIC_EMBED_TEXT # optional ) ``` diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index a71a8bd6..3493178e 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -11,6 +11,8 @@ client = Client.new graphql = Graphql.new(client) result = graphql.mutation( - query: {} + query: { + "query" => "mutation { accountUpdateName(name: "Walter") { name } }" + } ) ``` diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 49561b15..2432fd81 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -11,6 +11,8 @@ client = Client.new graphql = Graphql.new(client) result = graphql.query( - query: {} + query: { + "query" => "query { localeGet { ip } }" + } ) ``` diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index fa86a835..a68eec6f 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -13,7 +13,7 @@ messaging = Messaging.new(client) result = messaging.create_twilio_provider( provider_id: '', name: '', - from: '+12065550100', # optional + from: '', # optional account_sid: '', # optional auth_token: '', # optional enabled: false # optional diff --git a/docs/examples/mongo/update.md b/docs/examples/mongo/update.md index 792e1e0d..55f02acd 100644 --- a/docs/examples/mongo/update.md +++ b/docs/examples/mongo/update.md @@ -25,7 +25,7 @@ result = mongo.update( storage_autoscaling: false, # optional storage_autoscaling_threshold_percent: 50, # optional storage_autoscaling_max_gb: 0, # optional - metrics_trace_sample_rate: nil, # optional + metrics_trace_sample_rate: null, # optional metrics_slow_query_log_threshold_ms: 0, # optional sql_api_enabled: false, # optional sql_api_allowed_statements: [], # optional diff --git a/docs/examples/mysql/update.md b/docs/examples/mysql/update.md index 0d972eab..2ba792ea 100644 --- a/docs/examples/mysql/update.md +++ b/docs/examples/mysql/update.md @@ -25,7 +25,7 @@ result = mysql.update( storage_autoscaling: false, # optional storage_autoscaling_threshold_percent: 50, # optional storage_autoscaling_max_gb: 0, # optional - metrics_trace_sample_rate: nil, # optional + metrics_trace_sample_rate: null, # optional metrics_slow_query_log_threshold_ms: 0, # optional sql_api_enabled: false, # optional sql_api_allowed_statements: [], # optional diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md index 6576dbec..99818b87 100644 --- a/docs/examples/oauth2/approve.md +++ b/docs/examples/oauth2/approve.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 75f092a2..d4f058ce 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -22,7 +22,7 @@ result = oauth2.authorize_post( prompt: '', # optional max_age: 0, # optional authorization_details: '', # optional - resource: '', # optional + resource: [], # optional audience: '', # optional request_uri: '' # optional ) diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index d7d5befc..474e4e96 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -22,7 +22,7 @@ result = oauth2.authorize( prompt: '', # optional max_age: 0, # optional authorization_details: '', # optional - resource: '', # 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 index 102671db..3fde848d 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -14,7 +14,7 @@ result = oauth2.create_device_authorization( client_id: '', # optional scope: '', # optional authorization_details: '', # optional - resource: '', # optional + resource: [], # optional audience: '' # optional ) ``` diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md index 9184cbf7..f4bff9f2 100644 --- a/docs/examples/oauth2/create-grant.md +++ b/docs/examples/oauth2/create-grant.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index 192e5ff1..2ac703ea 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -22,7 +22,7 @@ result = oauth2.create_par( prompt: '', # optional max_age: 0, # optional authorization_details: '', # optional - resource: '', # optional + resource: [], # optional audience: '' # optional ) ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index 6e0cabc1..8b0a9c52 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -19,7 +19,7 @@ result = oauth2.create_token( client_secret: '', # optional code_verifier: '', # optional redirect_uri: 'https://example.com', # optional - resource: '', # optional + resource: [], # optional audience: '' # optional ) ``` diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md index e6b80763..81985286 100644 --- a/docs/examples/oauth2/get-grant.md +++ b/docs/examples/oauth2/get-grant.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md index 28b026e4..2e9ed664 100644 --- a/docs/examples/oauth2/list-organizations.md +++ b/docs/examples/oauth2/list-organizations.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md index 3f8c64f2..f7a69362 100644 --- a/docs/examples/oauth2/list-projects.md +++ b/docs/examples/oauth2/list-projects.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md index bf00d990..e10fd752 100644 --- a/docs/examples/oauth2/reject.md +++ b/docs/examples/oauth2/reject.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md index 6b709451..36c5c145 100644 --- a/docs/examples/oauth2/revoke.md +++ b/docs/examples/oauth2/revoke.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/organization/create-key.md b/docs/examples/organization/create-key.md deleted file mode 100644 index 3d920ccc..00000000 --- a/docs/examples/organization/create-key.md +++ /dev/null @@ -1,20 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite -include Appwrite::Enums - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -organization = Organization.new(client) - -result = organization.create_key( - key_id: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTS_READ], - expire: '2020-10-15T06:38:00.000+00:00' # optional -) -``` diff --git a/docs/examples/organization/delete-key.md b/docs/examples/organization/delete-key.md deleted file mode 100644 index 0e490c3b..00000000 --- a/docs/examples/organization/delete-key.md +++ /dev/null @@ -1,16 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -organization = Organization.new(client) - -result = organization.delete_key( - key_id: '' -) -``` diff --git a/docs/examples/organization/get-key.md b/docs/examples/organization/get-key.md deleted file mode 100644 index 28899bb6..00000000 --- a/docs/examples/organization/get-key.md +++ /dev/null @@ -1,16 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -organization = Organization.new(client) - -result = organization.get_key( - key_id: '' -) -``` diff --git a/docs/examples/organization/list-keys.md b/docs/examples/organization/list-keys.md deleted file mode 100644 index d54a2642..00000000 --- a/docs/examples/organization/list-keys.md +++ /dev/null @@ -1,17 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -organization = Organization.new(client) - -result = organization.list_keys( - queries: [], # optional - total: false # optional -) -``` diff --git a/docs/examples/organization/update-key.md b/docs/examples/organization/update-key.md deleted file mode 100644 index c7542126..00000000 --- a/docs/examples/organization/update-key.md +++ /dev/null @@ -1,20 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite -include Appwrite::Enums - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -organization = Organization.new(client) - -result = organization.update_key( - key_id: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTS_READ], - expire: '2020-10-15T06:38:00.000+00:00' # optional -) -``` diff --git a/docs/examples/postgresql/update.md b/docs/examples/postgresql/update.md index 48d76044..f43a9e88 100644 --- a/docs/examples/postgresql/update.md +++ b/docs/examples/postgresql/update.md @@ -25,7 +25,7 @@ result = postgresql.update( storage_autoscaling: false, # optional storage_autoscaling_threshold_percent: 50, # optional storage_autoscaling_max_gb: 0, # optional - metrics_trace_sample_rate: nil, # optional + metrics_trace_sample_rate: null, # optional metrics_slow_query_log_threshold_ms: 0, # optional sql_api_enabled: false, # optional sql_api_allowed_statements: [], # optional diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index 6f0d9b66..d7928fa5 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -12,7 +12,7 @@ client = Client.new project = Project.new(client) result = project.create_ephemeral_key( - scopes: [ProjectKeyScopes::PROJECT_READ], + scopes: [ProjectKeyScopes::USERS_READ], duration: 600 ) ``` diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index 1e1d1eae..34853638 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -11,6 +11,6 @@ client = Client.new project = Project.new(client) result = project.create_smtp_test( - emails: [] + emails: ["recipient@example.com"] ) ``` diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index b192315d..992775bb 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -14,7 +14,7 @@ project = Project.new(client) result = project.update_key( key_id: '', name: '', - scopes: [ProjectKeyScopes::PROJECT_READ], + scopes: [ProjectKeyScopes::USERS_READ], expire: '2020-10-15T06:38:00.000+00:00' # optional ) ``` diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index f57cec70..a01667b9 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -11,6 +11,6 @@ client = Client.new project = Project.new(client) result = project.update_labels( - labels: [] + labels: ["production"] ) ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index 035810f7..5acde9f9 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -14,7 +14,7 @@ project = Project.new(client) result = project.update_o_auth2_kakao( client_id: '', # optional client_secret: '', # optional - prompt: [ProjectOAuth2KakaoPrompt::NONE], # optional - enabled: false # optional + enabled: false, # optional + prompt: [ProjectOAuth2KakaoPrompt::NONE] # optional ) ``` diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index 3b4ce03d..d40c3a5e 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -16,7 +16,7 @@ result = storage.get_file_preview( file_id: '', width: 0, # optional height: 0, # optional - gravity: ImageGravity::CENTER, # optional + gravity: ImageGravity::AUTO, # optional quality: -1, # optional border_width: 0, # optional border_color: 'FFFFFF', # optional diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index a0453818..d1e2dba7 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -16,7 +16,7 @@ result = tables_db.create_index( table_id: '', key: '', type: TablesDBIndexType::KEY, - columns: [], + columns: ["username"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index 2fc8a2b1..9ff8dd78 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -13,7 +13,16 @@ tables_db = TablesDB.new(client) result = tables_db.create_rows( database_id: '', table_id: '', - rows: [], + rows: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 69ab29e8..41d6acdb 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -13,7 +13,7 @@ tables_db = TablesDB.new(client) result = tables_db.delete_rows( database_id: '', table_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index d450971f..9d5cce80 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -13,7 +13,16 @@ tables_db = TablesDB.new(client) result = tables_db.upsert_rows( database_id: '', table_id: '', - rows: [], + rows: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index c90a80d6..9016bb71 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -12,7 +12,7 @@ teams = Teams.new(client) result = teams.create_membership( team_id: '', - roles: [], + roles: ["editor"], email: 'email@example.com', # optional user_id: '', # optional phone: '+12065550100', # optional diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index f94e3879..898f7eae 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -13,6 +13,6 @@ teams = Teams.new(client) result = teams.update_membership( team_id: '', membership_id: '', - roles: [] + roles: ["editor"] ) ``` diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md deleted file mode 100644 index dd9809e3..00000000 --- a/docs/examples/users/list-logs.md +++ /dev/null @@ -1,18 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -users = Users.new(client) - -result = users.list_logs( - user_id: '', - queries: [], # optional - total: false # optional -) -``` diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 0110cb9e..bdad6d04 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -12,6 +12,6 @@ users = Users.new(client) result = users.update_labels( user_id: '', - labels: [] + labels: ["subscriber"] ) ``` diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md index b449f541..4b16940b 100644 --- a/docs/examples/vectorsdb/create-collection.md +++ b/docs/examples/vectorsdb/create-collection.md @@ -16,7 +16,7 @@ result = vectors_db.create_collection( database_id: '', collection_id: '', name: '', - dimension: 1, + dimension: 4, permissions: [Permission.read(Role.any())], # optional document_security: false, # optional enabled: false # optional diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index 9f3a4d4d..3a89c1ee 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -13,7 +13,20 @@ vectors_db = VectorsDB.new(client) result = vectors_db.create_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md index d7880ab2..60d2624a 100644 --- a/docs/examples/vectorsdb/create-index.md +++ b/docs/examples/vectorsdb/create-index.md @@ -16,7 +16,7 @@ result = vectors_db.create_index( collection_id: '', key: '', type: VectorsDBIndexType::HNSW_EUCLIDEAN, - attributes: [], + attributes: ["embeddings"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md index 6817930b..23e14d1c 100644 --- a/docs/examples/vectorsdb/create-operations.md +++ b/docs/examples/vectorsdb/create-operations.md @@ -19,7 +19,15 @@ result = vectors_db.create_operations( "collectionId": "", "documentId": "", "data": { - "name": "Walter O'Brien" + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } } } ] # optional diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md index bb1173a3..a050c8c3 100644 --- a/docs/examples/vectorsdb/delete-documents.md +++ b/docs/examples/vectorsdb/delete-documents.md @@ -13,7 +13,7 @@ vectors_db = VectorsDB.new(client) result = vectors_db.delete_documents( database_id: '', collection_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md index 0dfdac13..eee8c975 100644 --- a/docs/examples/vectorsdb/update-collection.md +++ b/docs/examples/vectorsdb/update-collection.md @@ -16,7 +16,7 @@ result = vectors_db.update_collection( database_id: '', collection_id: '', name: '', - dimension: 1, # optional + dimension: 4, # optional permissions: [Permission.read(Role.any())], # optional document_security: false, # optional enabled: false # optional diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md index d737f107..e1fea6cc 100644 --- a/docs/examples/vectorsdb/upsert-documents.md +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -13,7 +13,20 @@ vectors_db = VectorsDB.new(client) result = vectors_db.upsert_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index 9f231f7b..6d754424 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -14,7 +14,7 @@ result = webhooks.create( webhook_id: '', url: 'https://example.com/webhook', name: '', - events: [], + events: ["users.*.create"], enabled: false, # optional tls: false, # optional auth_username: '', # optional diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index ad3fa894..859d15f2 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -14,7 +14,7 @@ result = webhooks.update( webhook_id: '', name: '', url: 'https://example.com/webhook', - events: [], + events: ["users.*.create"], enabled: false, # optional tls: false, # optional auth_username: '', # optional diff --git a/lib/appwrite.rb b/lib/appwrite.rb index 7cf6053d..d4915ce5 100644 --- a/lib/appwrite.rb +++ b/lib/appwrite.rb @@ -24,7 +24,6 @@ require_relative 'appwrite/models/user_list' require_relative 'appwrite/models/session_list' require_relative 'appwrite/models/identity_list' -require_relative 'appwrite/models/log_list' require_relative 'appwrite/models/file_list' require_relative 'appwrite/models/bucket_list' require_relative 'appwrite/models/resource_token_list' @@ -111,7 +110,6 @@ require_relative 'appwrite/models/row' require_relative 'appwrite/models/document' require_relative 'appwrite/models/presence' -require_relative 'appwrite/models/log' require_relative 'appwrite/models/user' require_relative 'appwrite/models/algo_md5' require_relative 'appwrite/models/algo_sha' @@ -147,7 +145,6 @@ require_relative 'appwrite/models/webhook' require_relative 'appwrite/models/key' require_relative 'appwrite/models/ephemeral_key' -require_relative 'appwrite/models/dev_key' require_relative 'appwrite/models/mock_number' require_relative 'appwrite/models/o_auth2_github' require_relative 'appwrite/models/o_auth2_discord' @@ -211,6 +208,10 @@ require_relative 'appwrite/models/policy_membership_privacy' require_relative 'appwrite/models/policy_mfa_factors' require_relative 'appwrite/models/policy_passkey' +require_relative 'appwrite/models/policy_deny_aliased_email' +require_relative 'appwrite/models/policy_deny_disposable_email' +require_relative 'appwrite/models/policy_deny_free_email' +require_relative 'appwrite/models/policy_deny_corporate_email' require_relative 'appwrite/models/platform_web' require_relative 'appwrite/models/platform_apple' require_relative 'appwrite/models/platform_android' @@ -280,10 +281,6 @@ require_relative 'appwrite/models/organization' require_relative 'appwrite/models/dedicated_database_pitr_windows' require_relative 'appwrite/models/backup_policy' -require_relative 'appwrite/models/policy_deny_aliased_email' -require_relative 'appwrite/models/policy_deny_disposable_email' -require_relative 'appwrite/models/policy_deny_free_email' -require_relative 'appwrite/models/policy_deny_corporate_email' require_relative 'appwrite/models/dedicated_database_pooler' require_relative 'appwrite/models/postgres_extension' require_relative 'appwrite/models/program' @@ -291,7 +288,6 @@ require_relative 'appwrite/models/dedicated_database_restoration_list' 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' @@ -366,7 +362,6 @@ require_relative 'appwrite/enums/execution_method' require_relative 'appwrite/enums/message_priority' require_relative 'appwrite/enums/smtp_encryption' -require_relative 'appwrite/enums/organization_key_scopes' require_relative 'appwrite/enums/region' require_relative 'appwrite/enums/project_auth_method_id' require_relative 'appwrite/enums/project_o_auth2_auth0_prompt' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index 99f8f563..caae8247 100644 --- a/lib/appwrite/client.rb +++ b/lib/appwrite/client.rb @@ -14,8 +14,8 @@ def initialize 'x-sdk-name' => 'Ruby', 'x-sdk-platform' => 'server', 'x-sdk-language' => 'ruby', - 'x-sdk-version' => '28.4.0', - 'X-Appwrite-Response-Format' => '2.0.0' + 'x-sdk-version' => '29.0.0', + 'X-Appwrite-Response-Format' => '2.5.0' } @endpoint = 'https://cloud.appwrite.io/v1' @config = {} @@ -130,20 +130,6 @@ def set_forwarded_user_agent(value) self end - # Set DevKey - # - # Your secret dev API key - # - # @param [String] value The value to set for the DevKey header - # - # @return [self] - def set_dev_key(value) - add_header('x-appwrite-dev-key', value) - @config['devkey'] = value - - self - end - # Set Cookie # # The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @@ -283,6 +269,16 @@ def chunked_upload( ) input_file = params[param_name.to_sym] + if input_file.nil? + return call( + method: method, + path: path, + headers: headers, + params: params, + response_type: response_type, + ) + end + case input_file.source_type when 'path' size = ::File.size(input_file.path) @@ -290,7 +286,7 @@ def chunked_upload( size = input_file.data.bytesize end - if size < @chunk_size + if size <= @chunk_size || response_type == "text" if input_file.source_type == 'path' input_file.data = IO.read(input_file.path) end @@ -546,6 +542,8 @@ def decode_text(response) def encode_form_data(value, key = nil) case value when Hash + return encode_form_data(value.to_json, key) unless key.nil? + value.map { |k, v| encode_form_data(v, k) }.join when Array value.map { |v| encode_form_data(v, "#{key}[]") }.join diff --git a/lib/appwrite/enums/billing_plan_group.rb b/lib/appwrite/enums/billing_plan_group.rb index 1f3ca3cf..59fde6e6 100644 --- a/lib/appwrite/enums/billing_plan_group.rb +++ b/lib/appwrite/enums/billing_plan_group.rb @@ -1,7 +1,6 @@ module Appwrite module Enums module BillingPlanGroup - STARTER = 'starter' FREE = 'free' START = 'start' PRO = 'pro' diff --git a/lib/appwrite/enums/organization_key_scopes.rb b/lib/appwrite/enums/organization_key_scopes.rb deleted file mode 100644 index 9a8c7aa3..00000000 --- a/lib/appwrite/enums/organization_key_scopes.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Appwrite - module Enums - module OrganizationKeyScopes - PROJECTS_READ = 'projects.read' - PROJECTS_WRITE = 'projects.write' - DEVKEYS_READ = 'devKeys.read' - 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' - ORGANIZATION_WRITE = 'organization.write' - DOMAINS_READ = 'domains.read' - DOMAINS_WRITE = 'domains.write' - KEYS_READ = 'keys.read' - KEYS_WRITE = 'keys.write' - end - end -end diff --git a/lib/appwrite/models/activity_event.rb b/lib/appwrite/models/activity_event.rb index 34699a2b..ed92c606 100644 --- a/lib/appwrite/models/activity_event.rb +++ b/lib/appwrite/models/activity_event.rb @@ -96,6 +96,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "actorType" => "", "actorId" => "", "actorEmail" => "", "actorName" => "", "resourceParent" => "", "resourceType" => "", "resourceId" => "", "resource" => "", "event" => "", "userAgent" => "", "ip" => "", "mode" => "", "country" => "", "continentCode" => "", "city" => "", "subdivisions" => "", "isp" => "", "autonomousSystemNumber" => "", "autonomousSystemOrganization" => "", "connectionType" => "", "connectionUsageType" => "", "connectionOrganization" => "", "time" => "", "projectId" => "", "teamId" => "", "hostname" => "", "sdk" => "", "sdkVersion" => "" }.merge(map) ActivityEvent.new( id: map["$id"], actor_type: map["actorType"], diff --git a/lib/appwrite/models/activity_event_list.rb b/lib/appwrite/models/activity_event_list.rb index 6c8ebfe3..214f21cd 100644 --- a/lib/appwrite/models/activity_event_list.rb +++ b/lib/appwrite/models/activity_event_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "events" => [] }.merge(map) ActivityEventList.new( total: map["total"], events: map["events"].map { |it| ActivityEvent.from(map: it) } diff --git a/lib/appwrite/models/additional_resource.rb b/lib/appwrite/models/additional_resource.rb index 54d3ad41..fea38e38 100644 --- a/lib/appwrite/models/additional_resource.rb +++ b/lib/appwrite/models/additional_resource.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "unit" => "", "currency" => "", "price" => 0, "value" => 0, "invoiceDesc" => "" }.merge(map) AdditionalResource.new( name: map["name"], unit: map["unit"], diff --git a/lib/appwrite/models/algo_argon2.rb b/lib/appwrite/models/algo_argon2.rb index d2413e72..213dc487 100644 --- a/lib/appwrite/models/algo_argon2.rb +++ b/lib/appwrite/models/algo_argon2.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "type" => "argon2", "memoryCost" => 0, "timeCost" => 0, "threads" => 0 }.merge(map) AlgoArgon2.new( type: map["type"], memory_cost: map["memoryCost"], diff --git a/lib/appwrite/models/algo_bcrypt.rb b/lib/appwrite/models/algo_bcrypt.rb index 0407c819..13c7758c 100644 --- a/lib/appwrite/models/algo_bcrypt.rb +++ b/lib/appwrite/models/algo_bcrypt.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "bcrypt" }.merge(map) AlgoBcrypt.new( type: map["type"] ) diff --git a/lib/appwrite/models/algo_md5.rb b/lib/appwrite/models/algo_md5.rb index d7f315c9..0a79ce23 100644 --- a/lib/appwrite/models/algo_md5.rb +++ b/lib/appwrite/models/algo_md5.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "md5" }.merge(map) AlgoMd5.new( type: map["type"] ) diff --git a/lib/appwrite/models/algo_phpass.rb b/lib/appwrite/models/algo_phpass.rb index 496d2065..2a44c3b6 100644 --- a/lib/appwrite/models/algo_phpass.rb +++ b/lib/appwrite/models/algo_phpass.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "phpass" }.merge(map) AlgoPhpass.new( type: map["type"] ) diff --git a/lib/appwrite/models/algo_scrypt.rb b/lib/appwrite/models/algo_scrypt.rb index 7128bb2f..8cf555c8 100644 --- a/lib/appwrite/models/algo_scrypt.rb +++ b/lib/appwrite/models/algo_scrypt.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "type" => "scrypt", "costCpu" => 8, "costMemory" => 14, "costParallel" => 1, "length" => 64 }.merge(map) AlgoScrypt.new( type: map["type"], cost_cpu: map["costCpu"], diff --git a/lib/appwrite/models/algo_scrypt_modified.rb b/lib/appwrite/models/algo_scrypt_modified.rb index 8862154c..3a27d34d 100644 --- a/lib/appwrite/models/algo_scrypt_modified.rb +++ b/lib/appwrite/models/algo_scrypt_modified.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "type" => "scryptMod", "salt" => "", "saltSeparator" => "", "signerKey" => "" }.merge(map) AlgoScryptModified.new( type: map["type"], salt: map["salt"], diff --git a/lib/appwrite/models/algo_sha.rb b/lib/appwrite/models/algo_sha.rb index bd227d57..16dc3be8 100644 --- a/lib/appwrite/models/algo_sha.rb +++ b/lib/appwrite/models/algo_sha.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "sha" }.merge(map) AlgoSha.new( type: map["type"] ) diff --git a/lib/appwrite/models/app.rb b/lib/appwrite/models/app.rb index 5123fbd9..13af49c0 100644 --- a/lib/appwrite/models/app.rb +++ b/lib/appwrite/models/app.rb @@ -87,6 +87,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "description" => "", "clientUri" => "", "logoUri" => "", "privacyPolicyUrl" => "", "termsUrl" => "", "contacts" => [], "tagline" => "", "tags" => [], "labels" => [], "images" => [], "supportUrl" => "", "dataDeletionUrl" => "", "redirectUris" => [], "postLogoutRedirectUris" => [], "enabled" => true, "type" => "confidential", "deviceFlow" => false, "teamId" => "", "userId" => "", "installationScopes" => [], "installationRedirectUrl" => "", "secrets" => [] }.merge(map) App.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_installation.rb b/lib/appwrite/models/app_installation.rb index 32a12a3e..f5b42e6a 100644 --- a/lib/appwrite/models/app_installation.rb +++ b/lib/appwrite/models/app_installation.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "teamId" => "", "scopes" => [], "authorizationDetails" => [], "createdById" => "", "createdByName" => "" }.merge(map) AppInstallation.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_installation_list.rb b/lib/appwrite/models/app_installation_list.rb index d59981cc..0efb5504 100644 --- a/lib/appwrite/models/app_installation_list.rb +++ b/lib/appwrite/models/app_installation_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "installations" => [] }.merge(map) AppInstallationList.new( total: map["total"], installations: map["installations"].map { |it| AppInstallation.from(map: it) } diff --git a/lib/appwrite/models/app_key.rb b/lib/appwrite/models/app_key.rb index f1a457f8..ad9d93c0 100644 --- a/lib/appwrite/models/app_key.rb +++ b/lib/appwrite/models/app_key.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "secret" => "", "hint" => "", "createdById" => "", "createdByName" => "" }.merge(map) AppKey.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_key_list.rb b/lib/appwrite/models/app_key_list.rb index 3ec9ecd7..7d2af88f 100644 --- a/lib/appwrite/models/app_key_list.rb +++ b/lib/appwrite/models/app_key_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "keys" => [] }.merge(map) AppKeyList.new( total: map["total"], keys: map["keys"].map { |it| AppKey.from(map: it) } diff --git a/lib/appwrite/models/app_scope.rb b/lib/appwrite/models/app_scope.rb index c12c0ccc..bd068e37 100644 --- a/lib/appwrite/models/app_scope.rb +++ b/lib/appwrite/models/app_scope.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "value" => "", "description" => "", "type" => "", "category" => "", "deprecated" => false }.merge(map) AppScope.new( value: map["value"], description: map["description"], diff --git a/lib/appwrite/models/app_scope_list.rb b/lib/appwrite/models/app_scope_list.rb index 8a7b772b..82426a7c 100644 --- a/lib/appwrite/models/app_scope_list.rb +++ b/lib/appwrite/models/app_scope_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "scopes" => [] }.merge(map) AppScopeList.new( total: map["total"], scopes: map["scopes"].map { |it| AppScope.from(map: it) } diff --git a/lib/appwrite/models/app_secret.rb b/lib/appwrite/models/app_secret.rb index 4170d66c..f65846a8 100644 --- a/lib/appwrite/models/app_secret.rb +++ b/lib/appwrite/models/app_secret.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "secret" => "", "hint" => "", "createdById" => "", "createdByName" => "" }.merge(map) AppSecret.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_secret_list.rb b/lib/appwrite/models/app_secret_list.rb index d4da1d58..0f1b1a5b 100644 --- a/lib/appwrite/models/app_secret_list.rb +++ b/lib/appwrite/models/app_secret_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "secrets" => [] }.merge(map) AppSecretList.new( total: map["total"], secrets: map["secrets"].map { |it| AppSecret.from(map: it) } diff --git a/lib/appwrite/models/app_secret_plaintext.rb b/lib/appwrite/models/app_secret_plaintext.rb index d36c260a..de5ea6ec 100644 --- a/lib/appwrite/models/app_secret_plaintext.rb +++ b/lib/appwrite/models/app_secret_plaintext.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "secret" => "", "hint" => "", "createdById" => "", "createdByName" => "" }.merge(map) AppSecretPlaintext.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/apps_list.rb b/lib/appwrite/models/apps_list.rb index 354957bc..cff5c27a 100644 --- a/lib/appwrite/models/apps_list.rb +++ b/lib/appwrite/models/apps_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "apps" => [] }.merge(map) AppsList.new( total: map["total"], apps: map["apps"].map { |it| App.from(map: it) } diff --git a/lib/appwrite/models/attribute_bigint.rb b/lib/appwrite/models/attribute_bigint.rb index b2286d7a..3de6d81a 100644 --- a/lib/appwrite/models/attribute_bigint.rb +++ b/lib/appwrite/models/attribute_bigint.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeBigint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_boolean.rb b/lib/appwrite/models/attribute_boolean.rb index 145da450..3f594d2c 100644 --- a/lib/appwrite/models/attribute_boolean.rb +++ b/lib/appwrite/models/attribute_boolean.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeBoolean.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_datetime.rb b/lib/appwrite/models/attribute_datetime.rb index 2cd2387e..7d19713e 100644 --- a/lib/appwrite/models/attribute_datetime.rb +++ b/lib/appwrite/models/attribute_datetime.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeDatetime.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_email.rb b/lib/appwrite/models/attribute_email.rb index d3dc9589..808e07ce 100644 --- a/lib/appwrite/models/attribute_email.rb +++ b/lib/appwrite/models/attribute_email.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "email" }.merge(map) AttributeEmail.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_enum.rb b/lib/appwrite/models/attribute_enum.rb index 758db16d..5eadaece 100644 --- a/lib/appwrite/models/attribute_enum.rb +++ b/lib/appwrite/models/attribute_enum.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "elements" => [], "format" => "enum" }.merge(map) AttributeEnum.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_float.rb b/lib/appwrite/models/attribute_float.rb index fd4c2581..85fad7b5 100644 --- a/lib/appwrite/models/attribute_float.rb +++ b/lib/appwrite/models/attribute_float.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeFloat.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_integer.rb b/lib/appwrite/models/attribute_integer.rb index 0707b347..aeebffff 100644 --- a/lib/appwrite/models/attribute_integer.rb +++ b/lib/appwrite/models/attribute_integer.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeInteger.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_ip.rb b/lib/appwrite/models/attribute_ip.rb index 4ac5e3b2..09f75337 100644 --- a/lib/appwrite/models/attribute_ip.rb +++ b/lib/appwrite/models/attribute_ip.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "ip" }.merge(map) AttributeIp.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_line.rb b/lib/appwrite/models/attribute_line.rb index 23cda309..ca22747e 100644 --- a/lib/appwrite/models/attribute_line.rb +++ b/lib/appwrite/models/attribute_line.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeLine.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_list.rb b/lib/appwrite/models/attribute_list.rb index 4aafafbc..dad98609 100644 --- a/lib/appwrite/models/attribute_list.rb +++ b/lib/appwrite/models/attribute_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "attributes" => [] }.merge(map) AttributeList.new( total: map["total"], attributes: map["attributes"] diff --git a/lib/appwrite/models/attribute_longtext.rb b/lib/appwrite/models/attribute_longtext.rb index 55922b0a..40400db9 100644 --- a/lib/appwrite/models/attribute_longtext.rb +++ b/lib/appwrite/models/attribute_longtext.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeLongtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_mediumtext.rb b/lib/appwrite/models/attribute_mediumtext.rb index 0dea9331..cc8c0cd3 100644 --- a/lib/appwrite/models/attribute_mediumtext.rb +++ b/lib/appwrite/models/attribute_mediumtext.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeMediumtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_object.rb b/lib/appwrite/models/attribute_object.rb index ab85153d..01396202 100644 --- a/lib/appwrite/models/attribute_object.rb +++ b/lib/appwrite/models/attribute_object.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeObject.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_point.rb b/lib/appwrite/models/attribute_point.rb index b236cb17..f1dd0517 100644 --- a/lib/appwrite/models/attribute_point.rb +++ b/lib/appwrite/models/attribute_point.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributePoint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_polygon.rb b/lib/appwrite/models/attribute_polygon.rb index 44ce447a..b5298101 100644 --- a/lib/appwrite/models/attribute_polygon.rb +++ b/lib/appwrite/models/attribute_polygon.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributePolygon.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_relationship.rb b/lib/appwrite/models/attribute_relationship.rb index 9b8da81c..fe8b276c 100644 --- a/lib/appwrite/models/attribute_relationship.rb +++ b/lib/appwrite/models/attribute_relationship.rb @@ -51,6 +51,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "relationType" => "", "twoWay" => false, "twoWayKey" => "", "onDelete" => "restrict", "side" => "" }.merge(map) AttributeRelationship.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_string.rb b/lib/appwrite/models/attribute_string.rb index e5e27203..2f3499ca 100644 --- a/lib/appwrite/models/attribute_string.rb +++ b/lib/appwrite/models/attribute_string.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) AttributeString.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_text.rb b/lib/appwrite/models/attribute_text.rb index 3997ad15..9047c342 100644 --- a/lib/appwrite/models/attribute_text.rb +++ b/lib/appwrite/models/attribute_text.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeText.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_url.rb b/lib/appwrite/models/attribute_url.rb index 2353dc79..e6d62685 100644 --- a/lib/appwrite/models/attribute_url.rb +++ b/lib/appwrite/models/attribute_url.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "url" }.merge(map) AttributeUrl.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_varchar.rb b/lib/appwrite/models/attribute_varchar.rb index 3720b0e0..fe438fea 100644 --- a/lib/appwrite/models/attribute_varchar.rb +++ b/lib/appwrite/models/attribute_varchar.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) AttributeVarchar.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_vector.rb b/lib/appwrite/models/attribute_vector.rb index 3954eefd..8ea3f9d0 100644 --- a/lib/appwrite/models/attribute_vector.rb +++ b/lib/appwrite/models/attribute_vector.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) AttributeVector.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/backup_archive.rb b/lib/appwrite/models/backup_archive.rb index 71ea159d..20852c2d 100644 --- a/lib/appwrite/models/backup_archive.rb +++ b/lib/appwrite/models/backup_archive.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "policyId" => "", "status" => "", "migrationId" => "", "services" => [], "resources" => [] }.merge(map) BackupArchive.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/backup_archive_list.rb b/lib/appwrite/models/backup_archive_list.rb index 9c0cc7cc..848d268c 100644 --- a/lib/appwrite/models/backup_archive_list.rb +++ b/lib/appwrite/models/backup_archive_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "archives" => [] }.merge(map) BackupArchiveList.new( total: map["total"], archives: map["archives"].map { |it| BackupArchive.from(map: it) } diff --git a/lib/appwrite/models/backup_policy.rb b/lib/appwrite/models/backup_policy.rb index 6e8e0376..acd93e45 100644 --- a/lib/appwrite/models/backup_policy.rb +++ b/lib/appwrite/models/backup_policy.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "name" => "", "$createdAt" => "", "$updatedAt" => "", "services" => [], "resources" => [], "retention" => 1, "schedule" => "0 * * * *", "type" => "full", "enabled" => false }.merge(map) BackupPolicy.new( id: map["$id"], name: map["name"], diff --git a/lib/appwrite/models/backup_policy_list.rb b/lib/appwrite/models/backup_policy_list.rb index d5de4a5d..294aa8ca 100644 --- a/lib/appwrite/models/backup_policy_list.rb +++ b/lib/appwrite/models/backup_policy_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "policies" => [] }.merge(map) BackupPolicyList.new( total: map["total"], policies: map["policies"].map { |it| BackupPolicy.from(map: it) } diff --git a/lib/appwrite/models/backup_restoration.rb b/lib/appwrite/models/backup_restoration.rb index 61eb62f4..99ac22c0 100644 --- a/lib/appwrite/models/backup_restoration.rb +++ b/lib/appwrite/models/backup_restoration.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "archiveId" => "", "policyId" => "", "status" => "", "migrationId" => "", "services" => [], "resources" => [], "options" => {} }.merge(map) BackupRestoration.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/backup_restoration_list.rb b/lib/appwrite/models/backup_restoration_list.rb index 671e135b..8f6fb521 100644 --- a/lib/appwrite/models/backup_restoration_list.rb +++ b/lib/appwrite/models/backup_restoration_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "restorations" => [] }.merge(map) BackupRestorationList.new( total: map["total"], restorations: map["restorations"].map { |it| BackupRestoration.from(map: it) } diff --git a/lib/appwrite/models/billing_limits.rb b/lib/appwrite/models/billing_limits.rb index ef61643b..8eefd941 100644 --- a/lib/appwrite/models/billing_limits.rb +++ b/lib/appwrite/models/billing_limits.rb @@ -13,14 +13,14 @@ class BillingLimits attr_reader :budget_limit def initialize( - bandwidth:, - storage:, - users:, - executions:, - gb_hours:, - image_transformations:, - auth_phone:, - budget_limit: + bandwidth: 0, + storage: 0, + users: 0, + executions: 0, + gb_hours: 0, + image_transformations: 0, + auth_phone: 0, + budget_limit: 0 ) @bandwidth = bandwidth @storage = storage diff --git a/lib/appwrite/models/billing_plan.rb b/lib/appwrite/models/billing_plan.rb index 2a5b6644..80c8a90a 100644 --- a/lib/appwrite/models/billing_plan.rb +++ b/lib/appwrite/models/billing_plan.rb @@ -90,7 +90,7 @@ def initialize( storage:, image_transformations:, screenshots_generated:, - members:, + members: 0, webhooks:, waf_rules:, environments:, @@ -115,10 +115,10 @@ def initialize( topics:, auth_phone:, domains:, - activity_logs:, + activity_logs: 1, usage_logs:, - usage_logs_intervals:, - usage_aggregate_only_metrics:, + usage_logs_intervals: ["15m", "1h", "1d"], + usage_aggregate_only_metrics: [], project_inactivity_days:, alert_limit:, usage:, @@ -128,7 +128,7 @@ def initialize( email_branding:, requires_payment_method:, requires_billing_address:, - eligible_countries:, + eligible_countries: [], is_available:, self_service:, premium_support:, @@ -142,10 +142,10 @@ def initialize( supports_free_email_validation:, supports_corporate_email_validation:, supports_project_specific_roles:, - backups_enabled:, + backups_enabled: true, usage_per_project:, supported_addons:, - backup_policies:, + backup_policies: 0, deployment_size:, build_size:, functions_interval_minimum:, @@ -234,6 +234,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "name" => "", "desc" => "", "order" => 0, "price" => 0, "trial" => 0, "bandwidth" => 0, "storage" => 0, "imageTransformations" => 0, "screenshotsGenerated" => 0, "webhooks" => 0, "wafRules" => 0, "environments" => 0, "projects" => 0, "platforms" => 0, "users" => 0, "teams" => 0, "databases" => 0, "databasesReads" => 0, "databasesWrites" => 0, "databasesBatchSize" => 0, "buckets" => 0, "fileSize" => 0, "functions" => 0, "sites" => 0, "executions" => 0, "executionsRetentionCount" => 1000, "GBHours" => 0, "realtime" => 0, "realtimeMessages" => 0, "messages" => 0, "topics" => 0, "authPhone" => 0, "domains" => 0, "usageLogs" => 0, "projectInactivityDays" => 0, "alertLimit" => 80, "budgetCapEnabled" => false, "customSmtp" => false, "emailBranding" => false, "requiresPaymentMethod" => true, "requiresBillingAddress" => false, "isAvailable" => true, "selfService" => true, "premiumSupport" => true, "budgeting" => true, "supportsMockNumbers" => true, "supportsOrganizationRoles" => true, "supportsCredits" => false, "supportsDedicatedDatabases" => false, "supportsDisposableEmailValidation" => false, "supportsCanonicalEmailValidation" => false, "supportsFreeEmailValidation" => false, "supportsCorporateEmailValidation" => false, "supportsProjectSpecificRoles" => false, "usagePerProject" => true, "deploymentSize" => 0, "buildSize" => 0, "functionsIntervalMinimum" => 0, "databasesAllowEncrypt" => false, "databaseComputeCredit" => 0 }.merge(map) BillingPlan.new( id: map["$id"], name: map["name"], @@ -276,7 +277,7 @@ def self.from(map:) usage_aggregate_only_metrics: map["usageAggregateOnlyMetrics"], project_inactivity_days: map["projectInactivityDays"], alert_limit: map["alertLimit"], - usage: UsageBillingPlan.from(map: map["usage"]), + usage: map["usage"].nil? ? nil : UsageBillingPlan.from(map: map["usage"]), addons: BillingPlanAddon.from(map: map["addons"]), budget_cap_enabled: map["budgetCapEnabled"], custom_smtp: map["customSmtp"], @@ -356,7 +357,7 @@ def to_map "usageAggregateOnlyMetrics": @usage_aggregate_only_metrics, "projectInactivityDays": @project_inactivity_days, "alertLimit": @alert_limit, - "usage": @usage.to_map, + "usage": @usage&.to_map, "addons": @addons.to_map, "budgetCapEnabled": @budget_cap_enabled, "customSmtp": @custom_smtp, @@ -397,7 +398,6 @@ def to_map def validate_group(group) valid_group = [ - Appwrite::Enums::BillingPlanGroup::STARTER, Appwrite::Enums::BillingPlanGroup::FREE, Appwrite::Enums::BillingPlanGroup::START, Appwrite::Enums::BillingPlanGroup::PRO, diff --git a/lib/appwrite/models/billing_plan_addon_details.rb b/lib/appwrite/models/billing_plan_addon_details.rb index 3dc5e285..106badcc 100644 --- a/lib/appwrite/models/billing_plan_addon_details.rb +++ b/lib/appwrite/models/billing_plan_addon_details.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "supported" => false, "planIncluded" => 0, "limit" => 0, "type" => "numeric", "price" => 0, "value" => 0, "invoiceDesc" => "" }.merge(map) BillingPlanAddonDetails.new( supported: map["supported"], plan_included: map["planIncluded"], diff --git a/lib/appwrite/models/billing_plan_dedicated_database_limits.rb b/lib/appwrite/models/billing_plan_dedicated_database_limits.rb index 3e179ad2..a6c6bb7c 100644 --- a/lib/appwrite/models/billing_plan_dedicated_database_limits.rb +++ b/lib/appwrite/models/billing_plan_dedicated_database_limits.rb @@ -24,25 +24,25 @@ class BillingPlanDedicatedDatabaseLimits attr_reader :allowed_sync_modes def initialize( - min_cpu:, - max_cpu:, - min_memory_mb:, - max_memory_mb:, - min_storage_gb:, - max_storage_gb:, - max_replicas:, - max_connections:, - max_ip_allowlist_size:, - max_extensions:, - max_backup_retention_days:, - max_pitr_retention_days:, - max_sql_api_max_rows:, - max_sql_api_max_bytes:, - max_sql_api_timeout_seconds:, - max_sql_api_allowed_statements:, - allowed_sql_statements:, - allowed_storage_classes:, - allowed_sync_modes: + min_cpu: 0, + max_cpu: 0, + min_memory_mb: 0, + max_memory_mb: 0, + min_storage_gb: 0, + max_storage_gb: 0, + max_replicas: 0, + max_connections: 0, + max_ip_allowlist_size: 0, + max_extensions: 0, + max_backup_retention_days: 0, + max_pitr_retention_days: 0, + max_sql_api_max_rows: 0, + max_sql_api_max_bytes: 0, + max_sql_api_timeout_seconds: 0, + max_sql_api_allowed_statements: 0, + allowed_sql_statements: [], + allowed_storage_classes: [], + allowed_sync_modes: [] ) @min_cpu = min_cpu @max_cpu = max_cpu diff --git a/lib/appwrite/models/billing_plan_limits.rb b/lib/appwrite/models/billing_plan_limits.rb index 999a55bf..89f5235c 100644 --- a/lib/appwrite/models/billing_plan_limits.rb +++ b/lib/appwrite/models/billing_plan_limits.rb @@ -7,8 +7,8 @@ class BillingPlanLimits attr_reader :daily_credits def initialize( - credits:, - daily_credits: + credits: 0, + daily_credits: 0 ) @credits = credits @daily_credits = daily_credits diff --git a/lib/appwrite/models/billing_plan_supported_addons.rb b/lib/appwrite/models/billing_plan_supported_addons.rb index ea2d8078..430878ac 100644 --- a/lib/appwrite/models/billing_plan_supported_addons.rb +++ b/lib/appwrite/models/billing_plan_supported_addons.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "baa" => false, "premiumGeoDB" => false, "premiumGeoDBOrg" => false }.merge(map) BillingPlanSupportedAddons.new( baa: map["baa"], premium_geo_db: map["premiumGeoDB"], diff --git a/lib/appwrite/models/block.rb b/lib/appwrite/models/block.rb index 4a1c81a6..d022ac08 100644 --- a/lib/appwrite/models/block.rb +++ b/lib/appwrite/models/block.rb @@ -7,53 +7,30 @@ class Block attr_reader :resource_type attr_reader :resource_id attr_reader :mode - attr_reader :reason attr_reader :expired_at - attr_reader :project_name - attr_reader :region - attr_reader :organization_name - attr_reader :organization_id - attr_reader :billing_plan def initialize( created_at:, resource_type:, resource_id:, mode:, - reason:, - expired_at:, - project_name:, - region:, - organization_name:, - organization_id:, - billing_plan: + expired_at: ) @created_at = created_at @resource_type = resource_type @resource_id = resource_id @mode = mode - @reason = reason @expired_at = expired_at - @project_name = project_name - @region = region - @organization_name = organization_name - @organization_id = organization_id - @billing_plan = billing_plan end def self.from(map:) + map = { "$createdAt" => "", "resourceType" => "", "resourceId" => "", "mode" => "full" }.merge(map) Block.new( created_at: map["$createdAt"], resource_type: map["resourceType"], resource_id: map["resourceId"], mode: map["mode"], - reason: map["reason"], - expired_at: map["expiredAt"], - project_name: map["projectName"], - region: map["region"], - organization_name: map["organizationName"], - organization_id: map["organizationId"], - billing_plan: map["billingPlan"] + expired_at: map["expiredAt"] ) end @@ -63,13 +40,7 @@ def to_map "resourceType": @resource_type, "resourceId": @resource_id, "mode": @mode, - "reason": @reason, - "expiredAt": @expired_at, - "projectName": @project_name, - "region": @region, - "organizationName": @organization_name, - "organizationId": @organization_id, - "billingPlan": @billing_plan + "expiredAt": @expired_at } end end diff --git a/lib/appwrite/models/bucket.rb b/lib/appwrite/models/bucket.rb index c7e8af99..4729a406 100644 --- a/lib/appwrite/models/bucket.rb +++ b/lib/appwrite/models/bucket.rb @@ -51,6 +51,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "fileSecurity" => false, "name" => "", "enabled" => true, "maximumFileSize" => 0, "allowedFileExtensions" => [], "compression" => "", "encryption" => true, "antivirus" => true, "transformations" => true, "totalSize" => 0 }.merge(map) Bucket.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/bucket_list.rb b/lib/appwrite/models/bucket_list.rb index 7d3c15a2..4912786b 100644 --- a/lib/appwrite/models/bucket_list.rb +++ b/lib/appwrite/models/bucket_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "buckets" => [] }.merge(map) BucketList.new( total: map["total"], buckets: map["buckets"].map { |it| Bucket.from(map: it) } diff --git a/lib/appwrite/models/collection.rb b/lib/appwrite/models/collection.rb index 9e270f29..d0319ddd 100644 --- a/lib/appwrite/models/collection.rb +++ b/lib/appwrite/models/collection.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "databaseId" => "", "name" => "", "enabled" => true, "documentSecurity" => false, "attributes" => [], "indexes" => [], "bytesMax" => 0, "bytesUsed" => 0 }.merge(map) Collection.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/collection_list.rb b/lib/appwrite/models/collection_list.rb index e1e42d26..31b8f1b8 100644 --- a/lib/appwrite/models/collection_list.rb +++ b/lib/appwrite/models/collection_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "collections" => [] }.merge(map) CollectionList.new( total: map["total"], collections: map["collections"].map { |it| Collection.from(map: it) } diff --git a/lib/appwrite/models/column_bigint.rb b/lib/appwrite/models/column_bigint.rb index 3dfa471a..827dc9b0 100644 --- a/lib/appwrite/models/column_bigint.rb +++ b/lib/appwrite/models/column_bigint.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnBigint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_boolean.rb b/lib/appwrite/models/column_boolean.rb index 83baf4a5..24447056 100644 --- a/lib/appwrite/models/column_boolean.rb +++ b/lib/appwrite/models/column_boolean.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnBoolean.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_datetime.rb b/lib/appwrite/models/column_datetime.rb index 60122665..dc77c1b9 100644 --- a/lib/appwrite/models/column_datetime.rb +++ b/lib/appwrite/models/column_datetime.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnDatetime.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_email.rb b/lib/appwrite/models/column_email.rb index 574e47e5..94694463 100644 --- a/lib/appwrite/models/column_email.rb +++ b/lib/appwrite/models/column_email.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "email" }.merge(map) ColumnEmail.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_enum.rb b/lib/appwrite/models/column_enum.rb index 0f2bd545..6ef78955 100644 --- a/lib/appwrite/models/column_enum.rb +++ b/lib/appwrite/models/column_enum.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "elements" => [], "format" => "enum" }.merge(map) ColumnEnum.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_float.rb b/lib/appwrite/models/column_float.rb index 3c06c690..3260c161 100644 --- a/lib/appwrite/models/column_float.rb +++ b/lib/appwrite/models/column_float.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnFloat.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_index.rb b/lib/appwrite/models/column_index.rb index 478d4c23..3b4f89bc 100644 --- a/lib/appwrite/models/column_index.rb +++ b/lib/appwrite/models/column_index.rb @@ -24,7 +24,7 @@ def initialize( error:, columns:, lengths:, - orders: + orders: [] ) @id = id @created_at = created_at @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "key" => "", "type" => "", "status" => "", "error" => "", "columns" => [], "lengths" => [] }.merge(map) ColumnIndex.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/column_index_list.rb b/lib/appwrite/models/column_index_list.rb index 9278fd40..5aacf564 100644 --- a/lib/appwrite/models/column_index_list.rb +++ b/lib/appwrite/models/column_index_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "indexes" => [] }.merge(map) ColumnIndexList.new( total: map["total"], indexes: map["indexes"].map { |it| ColumnIndex.from(map: it) } diff --git a/lib/appwrite/models/column_integer.rb b/lib/appwrite/models/column_integer.rb index 0a71c44f..d58db0f7 100644 --- a/lib/appwrite/models/column_integer.rb +++ b/lib/appwrite/models/column_integer.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnInteger.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_ip.rb b/lib/appwrite/models/column_ip.rb index 3d4f6551..12b7ff0d 100644 --- a/lib/appwrite/models/column_ip.rb +++ b/lib/appwrite/models/column_ip.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "ip" }.merge(map) ColumnIp.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_line.rb b/lib/appwrite/models/column_line.rb index f8a14bf0..2ed8600e 100644 --- a/lib/appwrite/models/column_line.rb +++ b/lib/appwrite/models/column_line.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnLine.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_list.rb b/lib/appwrite/models/column_list.rb index 8d239ddf..a635a9b4 100644 --- a/lib/appwrite/models/column_list.rb +++ b/lib/appwrite/models/column_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "columns" => [] }.merge(map) ColumnList.new( total: map["total"], columns: map["columns"] diff --git a/lib/appwrite/models/column_longtext.rb b/lib/appwrite/models/column_longtext.rb index 5a112087..138b6315 100644 --- a/lib/appwrite/models/column_longtext.rb +++ b/lib/appwrite/models/column_longtext.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnLongtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_mediumtext.rb b/lib/appwrite/models/column_mediumtext.rb index c5b465c9..57fb8e40 100644 --- a/lib/appwrite/models/column_mediumtext.rb +++ b/lib/appwrite/models/column_mediumtext.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnMediumtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_point.rb b/lib/appwrite/models/column_point.rb index 34e5cf0e..b4f8cc75 100644 --- a/lib/appwrite/models/column_point.rb +++ b/lib/appwrite/models/column_point.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnPoint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_polygon.rb b/lib/appwrite/models/column_polygon.rb index 82f39732..b908f56a 100644 --- a/lib/appwrite/models/column_polygon.rb +++ b/lib/appwrite/models/column_polygon.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnPolygon.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_relationship.rb b/lib/appwrite/models/column_relationship.rb index c34643ea..22effc88 100644 --- a/lib/appwrite/models/column_relationship.rb +++ b/lib/appwrite/models/column_relationship.rb @@ -51,6 +51,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "relationType" => "", "twoWay" => false, "twoWayKey" => "", "onDelete" => "restrict", "side" => "" }.merge(map) ColumnRelationship.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_string.rb b/lib/appwrite/models/column_string.rb index 6e08f2f5..fea53cf3 100644 --- a/lib/appwrite/models/column_string.rb +++ b/lib/appwrite/models/column_string.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) ColumnString.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_text.rb b/lib/appwrite/models/column_text.rb index c3c7afb0..a72bd581 100644 --- a/lib/appwrite/models/column_text.rb +++ b/lib/appwrite/models/column_text.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnText.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_url.rb b/lib/appwrite/models/column_url.rb index 11829a7d..4cd93199 100644 --- a/lib/appwrite/models/column_url.rb +++ b/lib/appwrite/models/column_url.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "url" }.merge(map) ColumnUrl.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_varchar.rb b/lib/appwrite/models/column_varchar.rb index 1a1083d7..bf84a3e8 100644 --- a/lib/appwrite/models/column_varchar.rb +++ b/lib/appwrite/models/column_varchar.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) ColumnVarchar.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/continent.rb b/lib/appwrite/models/continent.rb index 861ec29f..64190bbc 100644 --- a/lib/appwrite/models/continent.rb +++ b/lib/appwrite/models/continent.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "code" => "" }.merge(map) Continent.new( name: map["name"], code: map["code"] diff --git a/lib/appwrite/models/continent_list.rb b/lib/appwrite/models/continent_list.rb index a5312493..f6a8c658 100644 --- a/lib/appwrite/models/continent_list.rb +++ b/lib/appwrite/models/continent_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "continents" => [] }.merge(map) ContinentList.new( total: map["total"], continents: map["continents"].map { |it| Continent.from(map: it) } diff --git a/lib/appwrite/models/country.rb b/lib/appwrite/models/country.rb index 07659799..7943e2cb 100644 --- a/lib/appwrite/models/country.rb +++ b/lib/appwrite/models/country.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "code" => "" }.merge(map) Country.new( name: map["name"], code: map["code"] diff --git a/lib/appwrite/models/country_list.rb b/lib/appwrite/models/country_list.rb index 1611dda7..7e537feb 100644 --- a/lib/appwrite/models/country_list.rb +++ b/lib/appwrite/models/country_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "countries" => [] }.merge(map) CountryList.new( total: map["total"], countries: map["countries"].map { |it| Country.from(map: it) } diff --git a/lib/appwrite/models/currency.rb b/lib/appwrite/models/currency.rb index b89e48ab..b9ebad26 100644 --- a/lib/appwrite/models/currency.rb +++ b/lib/appwrite/models/currency.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "symbol" => "", "name" => "", "symbolNative" => "", "decimalDigits" => 0, "rounding" => 0, "code" => "", "namePlural" => "" }.merge(map) Currency.new( symbol: map["symbol"], name: map["name"], diff --git a/lib/appwrite/models/currency_list.rb b/lib/appwrite/models/currency_list.rb index 53d23594..663aec21 100644 --- a/lib/appwrite/models/currency_list.rb +++ b/lib/appwrite/models/currency_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "currencies" => [] }.merge(map) CurrencyList.new( total: map["total"], currencies: map["currencies"].map { |it| Currency.from(map: it) } diff --git a/lib/appwrite/models/database.rb b/lib/appwrite/models/database.rb index d0408fc8..48d62333 100644 --- a/lib/appwrite/models/database.rb +++ b/lib/appwrite/models/database.rb @@ -54,6 +54,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "name" => "", "$createdAt" => "", "$updatedAt" => "", "enabled" => true, "type" => "legacy" }.merge(map) Database.new( id: map["$id"], name: map["name"], diff --git a/lib/appwrite/models/database_list.rb b/lib/appwrite/models/database_list.rb index 37c83aab..7b008d97 100644 --- a/lib/appwrite/models/database_list.rb +++ b/lib/appwrite/models/database_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "databases" => [] }.merge(map) DatabaseList.new( total: map["total"], databases: map["databases"].map { |it| Database.from(map: it) } diff --git a/lib/appwrite/models/database_migration.rb b/lib/appwrite/models/database_migration.rb index 75becc38..d0b4071d 100644 --- a/lib/appwrite/models/database_migration.rb +++ b/lib/appwrite/models/database_migration.rb @@ -60,6 +60,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "projectId" => "", "databaseId" => "", "specification" => "", "phase" => "pending", "attempt" => 0, "lastError" => "", "lagDocuments" => 0, "changelogWatermark" => 0, "verifiedAt" => "", "cutoverAt" => "", "soakUntil" => "", "autoCutover" => true, "cutoverRequested" => false, "paused" => false }.merge(map) DatabaseMigration.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/database_migration_list.rb b/lib/appwrite/models/database_migration_list.rb index 21730266..f42c1c2f 100644 --- a/lib/appwrite/models/database_migration_list.rb +++ b/lib/appwrite/models/database_migration_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "migrations" => [] }.merge(map) DatabaseMigrationList.new( total: map["total"], migrations: map["migrations"].map { |it| DatabaseMigration.from(map: it) } diff --git a/lib/appwrite/models/database_status.rb b/lib/appwrite/models/database_status.rb index f4a609c1..8fd8ca01 100644 --- a/lib/appwrite/models/database_status.rb +++ b/lib/appwrite/models/database_status.rb @@ -51,13 +51,14 @@ def initialize( end def self.from(map:) + map = { "health" => "unknown", "ready" => false, "engine" => "postgresql", "version" => "", "uptime" => 0, "syncMode" => "async", "syncDegraded" => false, "syncAcknowledgements" => 0, "syncStandbyCount" => 0, "replicas" => [], "volumes" => [] }.merge(map) DatabaseStatus.new( health: map["health"], ready: map["ready"], engine: map["engine"], version: map["version"], uptime: map["uptime"], - connections: DatabaseStatusConnections.from(map: map["connections"]), + connections: map["connections"].nil? ? nil : DatabaseStatusConnections.from(map: map["connections"]), sync_mode: map["syncMode"], effective_sync_mode: map["effectiveSyncMode"], sync_degraded: map["syncDegraded"], @@ -76,7 +77,7 @@ def to_map "engine": @engine, "version": @version, "uptime": @uptime, - "connections": @connections.to_map, + "connections": @connections&.to_map, "syncMode": @sync_mode, "effectiveSyncMode": @effective_sync_mode, "syncDegraded": @sync_degraded, diff --git a/lib/appwrite/models/database_status_connections.rb b/lib/appwrite/models/database_status_connections.rb index 623156df..22104215 100644 --- a/lib/appwrite/models/database_status_connections.rb +++ b/lib/appwrite/models/database_status_connections.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "current" => 0, "max" => 100 }.merge(map) DatabaseStatusConnections.new( current: map["current"], max: map["max"] diff --git a/lib/appwrite/models/database_status_replica.rb b/lib/appwrite/models/database_status_replica.rb index 7ed53873..5b499990 100644 --- a/lib/appwrite/models/database_status_replica.rb +++ b/lib/appwrite/models/database_status_replica.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "index" => 0, "role" => "unknown", "healthy" => false }.merge(map) DatabaseStatusReplica.new( index: map["index"], role: map["role"], diff --git a/lib/appwrite/models/database_status_volume.rb b/lib/appwrite/models/database_status_volume.rb index cd15505b..03c314eb 100644 --- a/lib/appwrite/models/database_status_volume.rb +++ b/lib/appwrite/models/database_status_volume.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "path" => "", "usedPercent" => "0%", "available" => "0GB", "mounted" => false }.merge(map) DatabaseStatusVolume.new( xpath: map["path"], used_percent: map["usedPercent"], diff --git a/lib/appwrite/models/dedicated_database.rb b/lib/appwrite/models/dedicated_database.rb index ca683b57..e9c87d7f 100644 --- a/lib/appwrite/models/dedicated_database.rb +++ b/lib/appwrite/models/dedicated_database.rb @@ -165,6 +165,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "projectId" => "", "name" => "", "version" => "", "specification" => "", "backend" => "", "hostname" => "", "connectionUser" => "", "connectionPassword" => "", "connectionString" => "", "ssl" => false, "status" => "provisioning", "containerStatus" => "", "lifecycleState" => "", "idleTimeoutMinutes" => 15, "cpu" => 500, "memory" => 512, "storage" => 10, "storageStatus" => "idle", "storageTargetGb" => 0, "storageClass" => "ssd", "storageMaxGb" => 0, "nodePool" => "", "replicas" => 0, "syncMode" => "", "networkMaxConnections" => 100, "networkIdleTimeoutSeconds" => 900, "networkIPAllowlist" => [], "backupEnabled" => true, "pitr" => true, "pitrRetentionDays" => 7, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, "storageAutoscalingMaxGb" => 0, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => false, "sqlApiEnabled" => true, "sqlApiAllowedStatements" => ["SELECT", "INSERT", "UPDATE", "DELETE"], "sqlApiMaxRows" => 10000, "sqlApiMaxBytes" => 10485760, "sqlApiTimeoutSeconds" => 30, "error" => "" }.merge(map) DedicatedDatabase.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/dedicated_database_backup.rb b/lib/appwrite/models/dedicated_database_backup.rb index f48b5d58..2fd522ed 100644 --- a/lib/appwrite/models/dedicated_database_backup.rb +++ b/lib/appwrite/models/dedicated_database_backup.rb @@ -60,6 +60,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "databaseId" => "", "projectId" => "", "policyId" => "", "trigger" => "manual", "type" => "full", "requestedType" => "", "fallbackReason" => "", "status" => "pending", "sizeBytes" => 0, "error" => "" }.merge(map) DedicatedDatabaseBackup.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/dedicated_database_backup_list.rb b/lib/appwrite/models/dedicated_database_backup_list.rb index 37d85ec0..c2c02187 100644 --- a/lib/appwrite/models/dedicated_database_backup_list.rb +++ b/lib/appwrite/models/dedicated_database_backup_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "backups" => [] }.merge(map) DedicatedDatabaseBackupList.new( total: map["total"], backups: map["backups"].map { |it| DedicatedDatabaseBackup.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_backup_storage.rb b/lib/appwrite/models/dedicated_database_backup_storage.rb index 3e1cb28b..aa2f1a2b 100644 --- a/lib/appwrite/models/dedicated_database_backup_storage.rb +++ b/lib/appwrite/models/dedicated_database_backup_storage.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "provider" => "", "bucket" => "", "region" => "", "prefix" => "backups/", "endpoint" => "" }.merge(map) DedicatedDatabaseBackupStorage.new( provider: map["provider"], bucket: map["bucket"], diff --git a/lib/appwrite/models/dedicated_database_branch.rb b/lib/appwrite/models/dedicated_database_branch.rb index 991728ca..52891c27 100644 --- a/lib/appwrite/models/dedicated_database_branch.rb +++ b/lib/appwrite/models/dedicated_database_branch.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "branchId" => "", "branchName" => "", "namespace" => "", "expiresAt" => 0, "host" => "", "database" => "", "username" => "", "password" => "", "ssl" => false, "engine" => "", "connectionString" => "" }.merge(map) DedicatedDatabaseBranch.new( branch_id: map["branchId"], branch_name: map["branchName"], diff --git a/lib/appwrite/models/dedicated_database_branch_list.rb b/lib/appwrite/models/dedicated_database_branch_list.rb index 106a3eb7..9ce8a978 100644 --- a/lib/appwrite/models/dedicated_database_branch_list.rb +++ b/lib/appwrite/models/dedicated_database_branch_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "branches" => [] }.merge(map) DedicatedDatabaseBranchList.new( total: map["total"], branches: map["branches"].map { |it| DedicatedDatabaseBranch.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_execution.rb b/lib/appwrite/models/dedicated_database_execution.rb index 49e247f3..8422db2d 100644 --- a/lib/appwrite/models/dedicated_database_execution.rb +++ b/lib/appwrite/models/dedicated_database_execution.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "rows" => [], "rowCount" => 0, "columns" => [], "durationMs" => 0, "truncated" => false, "bytes" => 0 }.merge(map) DedicatedDatabaseExecution.new( rows: map["rows"], row_count: map["rowCount"], diff --git a/lib/appwrite/models/dedicated_database_execution_column.rb b/lib/appwrite/models/dedicated_database_execution_column.rb index 4605650d..735dd40e 100644 --- a/lib/appwrite/models/dedicated_database_execution_column.rb +++ b/lib/appwrite/models/dedicated_database_execution_column.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "type" => "" }.merge(map) DedicatedDatabaseExecutionColumn.new( name: map["name"], type: map["type"] diff --git a/lib/appwrite/models/dedicated_database_extensions.rb b/lib/appwrite/models/dedicated_database_extensions.rb index 26c35a8e..559e09c2 100644 --- a/lib/appwrite/models/dedicated_database_extensions.rb +++ b/lib/appwrite/models/dedicated_database_extensions.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "installed" => [], "available" => [], "metadata" => [] }.merge(map) DedicatedDatabaseExtensions.new( installed: map["installed"], available: map["available"], diff --git a/lib/appwrite/models/dedicated_database_list.rb b/lib/appwrite/models/dedicated_database_list.rb index 3a66c939..79b8e45a 100644 --- a/lib/appwrite/models/dedicated_database_list.rb +++ b/lib/appwrite/models/dedicated_database_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "databases" => [] }.merge(map) DedicatedDatabaseList.new( total: map["total"], databases: map["databases"].map { |it| DedicatedDatabase.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_member.rb b/lib/appwrite/models/dedicated_database_member.rb index 8aaddc77..356dad04 100644 --- a/lib/appwrite/models/dedicated_database_member.rb +++ b/lib/appwrite/models/dedicated_database_member.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "role" => "unknown", "status" => "" }.merge(map) DedicatedDatabaseMember.new( id: map["$id"], role: map["role"], diff --git a/lib/appwrite/models/dedicated_database_operation.rb b/lib/appwrite/models/dedicated_database_operation.rb index bd6b53cf..112f0ada 100644 --- a/lib/appwrite/models/dedicated_database_operation.rb +++ b/lib/appwrite/models/dedicated_database_operation.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "databaseId" => "", "type" => "", "status" => "", "attempts" => 0, "errorCode" => "", "errorMessage" => "" }.merge(map) DedicatedDatabaseOperation.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/dedicated_database_operation_list.rb b/lib/appwrite/models/dedicated_database_operation_list.rb index d4985739..8b63a84b 100644 --- a/lib/appwrite/models/dedicated_database_operation_list.rb +++ b/lib/appwrite/models/dedicated_database_operation_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "operations" => [] }.merge(map) DedicatedDatabaseOperationList.new( total: map["total"], operations: map["operations"].map { |it| DedicatedDatabaseOperation.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_pitr_windows.rb b/lib/appwrite/models/dedicated_database_pitr_windows.rb index b80d115d..492f5bac 100644 --- a/lib/appwrite/models/dedicated_database_pitr_windows.rb +++ b/lib/appwrite/models/dedicated_database_pitr_windows.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "earliest" => "", "latest" => "" }.merge(map) DedicatedDatabasePITRWindows.new( earliest: map["earliest"], latest: map["latest"] diff --git a/lib/appwrite/models/dedicated_database_pooler.rb b/lib/appwrite/models/dedicated_database_pooler.rb index a87c1776..1804c09c 100644 --- a/lib/appwrite/models/dedicated_database_pooler.rb +++ b/lib/appwrite/models/dedicated_database_pooler.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => false, "mode" => "transaction", "maxConnections" => 100, "defaultPoolSize" => 20, "port" => 6432, "readWriteSplitting" => false, "poolerCpuRequest" => "", "poolerCpuLimit" => "", "poolerMemoryRequest" => "", "poolerMemoryLimit" => "" }.merge(map) DedicatedDatabasePooler.new( enabled: map["enabled"], mode: map["mode"], diff --git a/lib/appwrite/models/dedicated_database_replicas.rb b/lib/appwrite/models/dedicated_database_replicas.rb index 72106776..409c8b07 100644 --- a/lib/appwrite/models/dedicated_database_replicas.rb +++ b/lib/appwrite/models/dedicated_database_replicas.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "replicas" => 0, "syncMode" => "async", "syncDegraded" => false, "syncAcknowledgements" => 0, "syncStandbyCount" => 0, "members" => [] }.merge(map) DedicatedDatabaseReplicas.new( replicas: map["replicas"], sync_mode: map["syncMode"], diff --git a/lib/appwrite/models/dedicated_database_restoration.rb b/lib/appwrite/models/dedicated_database_restoration.rb index be6e9f26..8d4579a6 100644 --- a/lib/appwrite/models/dedicated_database_restoration.rb +++ b/lib/appwrite/models/dedicated_database_restoration.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "databaseId" => "", "projectId" => "", "type" => "backup", "status" => "pending", "error" => "" }.merge(map) DedicatedDatabaseRestoration.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/dedicated_database_restoration_list.rb b/lib/appwrite/models/dedicated_database_restoration_list.rb index dcb3f9ee..7755ec27 100644 --- a/lib/appwrite/models/dedicated_database_restoration_list.rb +++ b/lib/appwrite/models/dedicated_database_restoration_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "restorations" => [] }.merge(map) DedicatedDatabaseRestorationList.new( total: map["total"], restorations: map["restorations"].map { |it| DedicatedDatabaseRestoration.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_specification.rb b/lib/appwrite/models/dedicated_database_specification.rb index b5f26a33..2c0bc719 100644 --- a/lib/appwrite/models/dedicated_database_specification.rb +++ b/lib/appwrite/models/dedicated_database_specification.rb @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "slug" => "", "name" => "", "price" => 0, "storageOverageRate" => 0, "bandwidthOverageRate" => 0, "replicaRate" => 0, "pitrRate" => 0, "cpu" => 0, "memory" => 0, "maxConnections" => 0, "includedStorage" => 0, "includedBandwidth" => 0, "enabled" => false }.merge(map) DedicatedDatabaseSpecification.new( slug: map["slug"], name: map["name"], diff --git a/lib/appwrite/models/dedicated_database_specification_list.rb b/lib/appwrite/models/dedicated_database_specification_list.rb index 206eec28..e649aa18 100644 --- a/lib/appwrite/models/dedicated_database_specification_list.rb +++ b/lib/appwrite/models/dedicated_database_specification_list.rb @@ -5,31 +5,27 @@ module Models class DedicatedDatabaseSpecificationList attr_reader :specifications attr_reader :total - attr_reader :pricing def initialize( specifications:, - total:, - pricing: + total: ) @specifications = specifications @total = total - @pricing = pricing end def self.from(map:) + map = { "specifications" => [], "total" => 0 }.merge(map) DedicatedDatabaseSpecificationList.new( specifications: map["specifications"].map { |it| DedicatedDatabaseSpecification.from(map: it) }, - total: map["total"], - pricing: DedicatedDatabaseSpecificationPricing.from(map: map["pricing"]) + total: map["total"] ) end def to_map { "specifications": @specifications.map { |it| it.to_map }, - "total": @total, - "pricing": @pricing.to_map + "total": @total } end end diff --git a/lib/appwrite/models/dedicated_database_specification_pricing.rb b/lib/appwrite/models/dedicated_database_specification_pricing.rb deleted file mode 100644 index d6ef0ef8..00000000 --- a/lib/appwrite/models/dedicated_database_specification_pricing.rb +++ /dev/null @@ -1,42 +0,0 @@ -# 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 :pitr_rate - - def initialize( - storage_overage_rate:, - bandwidth_overage_rate:, - replica_rate:, - pitr_rate: - ) - @storage_overage_rate = storage_overage_rate - @bandwidth_overage_rate = bandwidth_overage_rate - @replica_rate = 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"], - pitr_rate: map["pitrRate"] - ) - end - - def to_map - { - "storageOverageRate": @storage_overage_rate, - "bandwidthOverageRate": @bandwidth_overage_rate, - "replicaRate": @replica_rate, - "pitrRate": @pitr_rate - } - end - end - end -end diff --git a/lib/appwrite/models/deployment.rb b/lib/appwrite/models/deployment.rb index 6fc3465b..c4749311 100644 --- a/lib/appwrite/models/deployment.rb +++ b/lib/appwrite/models/deployment.rb @@ -90,6 +90,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "type" => "", "resourceId" => "", "resourceType" => "", "entrypoint" => "", "sourceSize" => 0, "buildSize" => 0, "totalSize" => 0, "buildId" => "", "activate" => false, "screenshotLight" => "", "screenshotDark" => "", "buildLogs" => "", "buildDuration" => 0, "providerRepositoryName" => "", "providerRepositoryOwner" => "", "providerRepositoryUrl" => "", "providerCommitHash" => "", "providerCommitAuthorUrl" => "", "providerCommitAuthor" => "", "providerCommitMessage" => "", "providerCommitUrl" => "", "providerBranch" => "", "providerBranchUrl" => "" }.merge(map) Deployment.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/deployment_list.rb b/lib/appwrite/models/deployment_list.rb index f9a2d696..5ff996f5 100644 --- a/lib/appwrite/models/deployment_list.rb +++ b/lib/appwrite/models/deployment_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "deployments" => [] }.merge(map) DeploymentList.new( total: map["total"], deployments: map["deployments"].map { |it| Deployment.from(map: it) } diff --git a/lib/appwrite/models/dev_key.rb b/lib/appwrite/models/dev_key.rb deleted file mode 100644 index 4389e82a..00000000 --- a/lib/appwrite/models/dev_key.rb +++ /dev/null @@ -1,62 +0,0 @@ -# frozen_string_literal: true - -module Appwrite - module Models - class DevKey - attr_reader :id - attr_reader :created_at - attr_reader :updated_at - attr_reader :name - attr_reader :expire - attr_reader :secret - attr_reader :accessed_at - attr_reader :sdks - - def initialize( - id:, - created_at:, - updated_at:, - name:, - expire:, - secret:, - accessed_at:, - sdks: - ) - @id = id - @created_at = created_at - @updated_at = updated_at - @name = name - @expire = expire - @secret = secret - @accessed_at = accessed_at - @sdks = sdks - end - - def self.from(map:) - DevKey.new( - id: map["$id"], - created_at: map["$createdAt"], - updated_at: map["$updatedAt"], - name: map["name"], - expire: map["expire"], - secret: map["secret"], - accessed_at: map["accessedAt"], - sdks: map["sdks"] - ) - end - - def to_map - { - "$id": @id, - "$createdAt": @created_at, - "$updatedAt": @updated_at, - "name": @name, - "expire": @expire, - "secret": @secret, - "accessedAt": @accessed_at, - "sdks": @sdks - } - end - end - end -end diff --git a/lib/appwrite/models/document.rb b/lib/appwrite/models/document.rb index 0cc8a466..02ed60e3 100644 --- a/lib/appwrite/models/document.rb +++ b/lib/appwrite/models/document.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$sequence" => "", "$collectionId" => "", "$databaseId" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [] }.merge(map) Document.new( id: map["$id"], sequence: map["$sequence"], diff --git a/lib/appwrite/models/document_list.rb b/lib/appwrite/models/document_list.rb index 254e19e2..9a1c4f69 100644 --- a/lib/appwrite/models/document_list.rb +++ b/lib/appwrite/models/document_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "documents" => [] }.merge(map) DocumentList.new( total: map["total"], documents: map["documents"].map { |it| Document.from(map: it) } diff --git a/lib/appwrite/models/email_template.rb b/lib/appwrite/models/email_template.rb index 5cacd768..ee13cfb6 100644 --- a/lib/appwrite/models/email_template.rb +++ b/lib/appwrite/models/email_template.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "templateId" => "", "locale" => "", "message" => "", "senderName" => "", "senderEmail" => "", "replyToEmail" => "", "replyToName" => "", "subject" => "" }.merge(map) EmailTemplate.new( template_id: map["templateId"], locale: map["locale"], diff --git a/lib/appwrite/models/email_template_list.rb b/lib/appwrite/models/email_template_list.rb index fbc649f1..4334c55c 100644 --- a/lib/appwrite/models/email_template_list.rb +++ b/lib/appwrite/models/email_template_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "templates" => [] }.merge(map) EmailTemplateList.new( total: map["total"], templates: map["templates"].map { |it| EmailTemplate.from(map: it) } diff --git a/lib/appwrite/models/embedding.rb b/lib/appwrite/models/embedding.rb index 177a94f4..f7c9978d 100644 --- a/lib/appwrite/models/embedding.rb +++ b/lib/appwrite/models/embedding.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "model" => "", "dimension" => 0, "embedding" => [], "error" => "" }.merge(map) Embedding.new( model: map["model"], dimension: map["dimension"], diff --git a/lib/appwrite/models/embedding_list.rb b/lib/appwrite/models/embedding_list.rb index 848b50d4..10090e93 100644 --- a/lib/appwrite/models/embedding_list.rb +++ b/lib/appwrite/models/embedding_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "embeddings" => [] }.merge(map) EmbeddingList.new( total: map["total"], embeddings: map["embeddings"].map { |it| Embedding.from(map: it) } diff --git a/lib/appwrite/models/ephemeral_key.rb b/lib/appwrite/models/ephemeral_key.rb index 14761c4f..cdc9eb77 100644 --- a/lib/appwrite/models/ephemeral_key.rb +++ b/lib/appwrite/models/ephemeral_key.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "expire" => "", "scopes" => [], "secret" => "", "accessedAt" => "", "sdks" => [] }.merge(map) EphemeralKey.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/execution.rb b/lib/appwrite/models/execution.rb index 55a701d5..d95bbbfe 100644 --- a/lib/appwrite/models/execution.rb +++ b/lib/appwrite/models/execution.rb @@ -66,6 +66,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "resourceId" => "", "resourceType" => "functions", "deploymentId" => "", "requestMethod" => "", "requestPath" => "", "requestHeaders" => [], "responseStatusCode" => 0, "responseBody" => "", "responseHeaders" => [], "logs" => "", "errors" => "", "duration" => 0 }.merge(map) Execution.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/execution_list.rb b/lib/appwrite/models/execution_list.rb index 531551db..457400c3 100644 --- a/lib/appwrite/models/execution_list.rb +++ b/lib/appwrite/models/execution_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "executions" => [] }.merge(map) ExecutionList.new( total: map["total"], executions: map["executions"].map { |it| Execution.from(map: it) } diff --git a/lib/appwrite/models/file.rb b/lib/appwrite/models/file.rb index 66ee936b..d448ece2 100644 --- a/lib/appwrite/models/file.rb +++ b/lib/appwrite/models/file.rb @@ -57,6 +57,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "bucketId" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "name" => "", "folder" => "", "key" => "", "signature" => "", "mimeType" => "", "sizeOriginal" => 0, "sizeActual" => 0, "chunksTotal" => 0, "chunksUploaded" => 0, "encryption" => false, "compression" => "none" }.merge(map) File.new( id: map["$id"], bucket_id: map["bucketId"], diff --git a/lib/appwrite/models/file_list.rb b/lib/appwrite/models/file_list.rb index 7a033d5a..9aee37f8 100644 --- a/lib/appwrite/models/file_list.rb +++ b/lib/appwrite/models/file_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "files" => [] }.merge(map) FileList.new( total: map["total"], files: map["files"].map { |it| File.from(map: it) } diff --git a/lib/appwrite/models/framework.rb b/lib/appwrite/models/framework.rb index 98108bfe..4dcc1d52 100644 --- a/lib/appwrite/models/framework.rb +++ b/lib/appwrite/models/framework.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "name" => "", "buildRuntime" => "", "runtimes" => [], "adapters" => [] }.merge(map) Framework.new( key: map["key"], name: map["name"], diff --git a/lib/appwrite/models/framework_adapter.rb b/lib/appwrite/models/framework_adapter.rb index 81d06e20..7a35dce5 100644 --- a/lib/appwrite/models/framework_adapter.rb +++ b/lib/appwrite/models/framework_adapter.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "installCommand" => "", "buildCommand" => "", "outputDirectory" => "" }.merge(map) FrameworkAdapter.new( key: map["key"], install_command: map["installCommand"], diff --git a/lib/appwrite/models/framework_list.rb b/lib/appwrite/models/framework_list.rb index da86b56d..7f477fe7 100644 --- a/lib/appwrite/models/framework_list.rb +++ b/lib/appwrite/models/framework_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "frameworks" => [] }.merge(map) FrameworkList.new( total: map["total"], frameworks: map["frameworks"].map { |it| Framework.from(map: it) } diff --git a/lib/appwrite/models/function.rb b/lib/appwrite/models/function.rb index 6d8b38b7..a89407be 100644 --- a/lib/appwrite/models/function.rb +++ b/lib/appwrite/models/function.rb @@ -57,7 +57,7 @@ def initialize( vars:, events:, schedule:, - interval:, + interval: 0, timeout:, entrypoint:, commands:, @@ -108,6 +108,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "execute" => [], "name" => "", "enabled" => true, "live" => true, "logging" => true, "runtime" => "", "deploymentRetention" => 0, "deploymentId" => "", "deploymentCreatedAt" => "", "latestDeploymentId" => "", "latestDeploymentCreatedAt" => "", "latestDeploymentStatus" => "", "scopes" => [], "vars" => [], "events" => [], "schedule" => "", "timeout" => 15, "entrypoint" => "", "commands" => "", "version" => "v5", "installationId" => "", "providerRepositoryId" => "", "providerBranch" => "", "providerRootDirectory" => "", "providerSilentMode" => false, "providerBranches" => [], "providerPaths" => [], "buildSpecification" => "s-1vcpu-512mb", "runtimeSpecification" => "s-1vcpu-512mb" }.merge(map) Function.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/function_list.rb b/lib/appwrite/models/function_list.rb index 8ac71cf1..554fdeb2 100644 --- a/lib/appwrite/models/function_list.rb +++ b/lib/appwrite/models/function_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "functions" => [] }.merge(map) FunctionList.new( total: map["total"], functions: map["functions"].map { |it| Function.from(map: it) } diff --git a/lib/appwrite/models/headers.rb b/lib/appwrite/models/headers.rb index 5c43bea8..270773e3 100644 --- a/lib/appwrite/models/headers.rb +++ b/lib/appwrite/models/headers.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "value" => "" }.merge(map) Headers.new( name: map["name"], value: map["value"] diff --git a/lib/appwrite/models/identity.rb b/lib/appwrite/models/identity.rb index abf586a2..4261f302 100644 --- a/lib/appwrite/models/identity.rb +++ b/lib/appwrite/models/identity.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "provider" => "", "providerUid" => "", "providerEmail" => "", "providerAccessToken" => "", "providerAccessTokenExpiry" => "", "providerRefreshToken" => "", "providerIdToken" => "" }.merge(map) Identity.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/identity_list.rb b/lib/appwrite/models/identity_list.rb index bef444be..18d48d2f 100644 --- a/lib/appwrite/models/identity_list.rb +++ b/lib/appwrite/models/identity_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "identities" => [] }.merge(map) IdentityList.new( total: map["total"], identities: map["identities"].map { |it| Identity.from(map: it) } diff --git a/lib/appwrite/models/index.rb b/lib/appwrite/models/index.rb index 20b6e62b..da063ec1 100644 --- a/lib/appwrite/models/index.rb +++ b/lib/appwrite/models/index.rb @@ -24,7 +24,7 @@ def initialize( error:, attributes:, lengths:, - orders: + orders: [] ) @id = id @created_at = created_at @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "key" => "", "type" => "", "error" => "", "attributes" => [], "lengths" => [] }.merge(map) Index.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/index_list.rb b/lib/appwrite/models/index_list.rb index a0795d16..a096b0c2 100644 --- a/lib/appwrite/models/index_list.rb +++ b/lib/appwrite/models/index_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "indexes" => [] }.merge(map) IndexList.new( total: map["total"], indexes: map["indexes"].map { |it| Index.from(map: it) } diff --git a/lib/appwrite/models/insight.rb b/lib/appwrite/models/insight.rb index a10df160..f2ede1a1 100644 --- a/lib/appwrite/models/insight.rb +++ b/lib/appwrite/models/insight.rb @@ -60,6 +60,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "reportId" => "", "type" => "", "severity" => "info", "status" => "active", "resourceType" => "", "resourceId" => "", "parentResourceType" => "", "parentResourceId" => "", "title" => "", "summary" => "", "ctas" => [] }.merge(map) Insight.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/insight_cta.rb b/lib/appwrite/models/insight_cta.rb index 36670cbe..1a92a732 100644 --- a/lib/appwrite/models/insight_cta.rb +++ b/lib/appwrite/models/insight_cta.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "label" => "", "service" => "", "method" => "", "params" => {} }.merge(map) InsightCTA.new( label: map["label"], service: map["service"], diff --git a/lib/appwrite/models/insight_list.rb b/lib/appwrite/models/insight_list.rb index af19aa84..70a1285b 100644 --- a/lib/appwrite/models/insight_list.rb +++ b/lib/appwrite/models/insight_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "insights" => [] }.merge(map) InsightList.new( total: map["total"], insights: map["insights"].map { |it| Insight.from(map: it) } diff --git a/lib/appwrite/models/jwt.rb b/lib/appwrite/models/jwt.rb index 73d8c92c..af1e7eb8 100644 --- a/lib/appwrite/models/jwt.rb +++ b/lib/appwrite/models/jwt.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "jwt" => "" }.merge(map) Jwt.new( jwt: map["jwt"] ) diff --git a/lib/appwrite/models/key.rb b/lib/appwrite/models/key.rb index 4df47cf3..5eb79318 100644 --- a/lib/appwrite/models/key.rb +++ b/lib/appwrite/models/key.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "expire" => "", "scopes" => [], "secret" => "", "accessedAt" => "", "sdks" => [] }.merge(map) Key.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/key_list.rb b/lib/appwrite/models/key_list.rb index d7a9649f..ac413cff 100644 --- a/lib/appwrite/models/key_list.rb +++ b/lib/appwrite/models/key_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "keys" => [] }.merge(map) KeyList.new( total: map["total"], keys: map["keys"].map { |it| Key.from(map: it) } diff --git a/lib/appwrite/models/language.rb b/lib/appwrite/models/language.rb index 8850a69b..b2acb8d8 100644 --- a/lib/appwrite/models/language.rb +++ b/lib/appwrite/models/language.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "code" => "", "nativeName" => "" }.merge(map) Language.new( name: map["name"], code: map["code"], diff --git a/lib/appwrite/models/language_list.rb b/lib/appwrite/models/language_list.rb index 118fc410..ec55d81e 100644 --- a/lib/appwrite/models/language_list.rb +++ b/lib/appwrite/models/language_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "languages" => [] }.merge(map) LanguageList.new( total: map["total"], languages: map["languages"].map { |it| Language.from(map: it) } diff --git a/lib/appwrite/models/locale.rb b/lib/appwrite/models/locale.rb index a31aea64..1fcb8607 100644 --- a/lib/appwrite/models/locale.rb +++ b/lib/appwrite/models/locale.rb @@ -63,6 +63,7 @@ def initialize( end def self.from(map:) + map = { "ip" => "", "countryCode" => "", "country" => "", "continentCode" => "", "continent" => "", "eu" => false, "currency" => "" }.merge(map) Locale.new( ip: map["ip"], country_code: map["countryCode"], diff --git a/lib/appwrite/models/locale_code.rb b/lib/appwrite/models/locale_code.rb index 6089272b..4795135c 100644 --- a/lib/appwrite/models/locale_code.rb +++ b/lib/appwrite/models/locale_code.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "code" => "", "name" => "" }.merge(map) LocaleCode.new( code: map["code"], name: map["name"] diff --git a/lib/appwrite/models/locale_code_list.rb b/lib/appwrite/models/locale_code_list.rb index b93213cb..e771b6d7 100644 --- a/lib/appwrite/models/locale_code_list.rb +++ b/lib/appwrite/models/locale_code_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "localeCodes" => [] }.merge(map) LocaleCodeList.new( total: map["total"], locale_codes: map["localeCodes"].map { |it| LocaleCode.from(map: it) } diff --git a/lib/appwrite/models/log.rb b/lib/appwrite/models/log.rb deleted file mode 100644 index 89e1a676..00000000 --- a/lib/appwrite/models/log.rb +++ /dev/null @@ -1,132 +0,0 @@ -# frozen_string_literal: true - -module Appwrite - module Models - class Log - attr_reader :event - attr_reader :user_id - attr_reader :user_email - attr_reader :user_name - attr_reader :mode - attr_reader :user_type - attr_reader :ip - attr_reader :time - attr_reader :os_code - attr_reader :os_name - attr_reader :os_version - attr_reader :client_type - attr_reader :client_code - attr_reader :client_name - attr_reader :client_version - attr_reader :client_engine - attr_reader :client_engine_version - attr_reader :device_name - attr_reader :device_brand - attr_reader :device_model - attr_reader :country_code - attr_reader :country_name - - def initialize( - event:, - user_id:, - user_email:, - user_name:, - mode:, - user_type:, - ip:, - time:, - os_code:, - os_name:, - os_version:, - client_type:, - client_code:, - client_name:, - client_version:, - client_engine:, - client_engine_version:, - device_name:, - device_brand:, - device_model:, - country_code:, - country_name: - ) - @event = event - @user_id = user_id - @user_email = user_email - @user_name = user_name - @mode = mode - @user_type = user_type - @ip = ip - @time = time - @os_code = os_code - @os_name = os_name - @os_version = os_version - @client_type = client_type - @client_code = client_code - @client_name = client_name - @client_version = client_version - @client_engine = client_engine - @client_engine_version = client_engine_version - @device_name = device_name - @device_brand = device_brand - @device_model = device_model - @country_code = country_code - @country_name = country_name - end - - def self.from(map:) - Log.new( - event: map["event"], - user_id: map["userId"], - user_email: map["userEmail"], - user_name: map["userName"], - mode: map["mode"], - user_type: map["userType"], - ip: map["ip"], - time: map["time"], - os_code: map["osCode"], - os_name: map["osName"], - os_version: map["osVersion"], - client_type: map["clientType"], - client_code: map["clientCode"], - client_name: map["clientName"], - client_version: map["clientVersion"], - client_engine: map["clientEngine"], - client_engine_version: map["clientEngineVersion"], - device_name: map["deviceName"], - device_brand: map["deviceBrand"], - device_model: map["deviceModel"], - country_code: map["countryCode"], - country_name: map["countryName"] - ) - end - - def to_map - { - "event": @event, - "userId": @user_id, - "userEmail": @user_email, - "userName": @user_name, - "mode": @mode, - "userType": @user_type, - "ip": @ip, - "time": @time, - "osCode": @os_code, - "osName": @os_name, - "osVersion": @os_version, - "clientType": @client_type, - "clientCode": @client_code, - "clientName": @client_name, - "clientVersion": @client_version, - "clientEngine": @client_engine, - "clientEngineVersion": @client_engine_version, - "deviceName": @device_name, - "deviceBrand": @device_brand, - "deviceModel": @device_model, - "countryCode": @country_code, - "countryName": @country_name - } - end - end - end -end diff --git a/lib/appwrite/models/log_list.rb b/lib/appwrite/models/log_list.rb deleted file mode 100644 index cdad965e..00000000 --- a/lib/appwrite/models/log_list.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -module Appwrite - module Models - class LogList - attr_reader :total - attr_reader :logs - - def initialize( - total:, - logs: - ) - @total = total - @logs = logs - end - - def self.from(map:) - LogList.new( - total: map["total"], - logs: map["logs"].map { |it| Log.from(map: it) } - ) - end - - def to_map - { - "total": @total, - "logs": @logs.map { |it| it.to_map } - } - end - end - end -end diff --git a/lib/appwrite/models/membership.rb b/lib/appwrite/models/membership.rb index 84b3ce1f..61e20c1d 100644 --- a/lib/appwrite/models/membership.rb +++ b/lib/appwrite/models/membership.rb @@ -54,6 +54,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "userName" => "", "userEmail" => "", "userPhone" => "", "teamId" => "", "teamName" => "", "invited" => "", "joined" => "", "confirm" => false, "mfa" => false, "userAccessedAt" => "", "roles" => [] }.merge(map) Membership.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/membership_list.rb b/lib/appwrite/models/membership_list.rb index 0cc220c0..dceb8db0 100644 --- a/lib/appwrite/models/membership_list.rb +++ b/lib/appwrite/models/membership_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "memberships" => [] }.merge(map) MembershipList.new( total: map["total"], memberships: map["memberships"].map { |it| Membership.from(map: it) } diff --git a/lib/appwrite/models/message.rb b/lib/appwrite/models/message.rb index 456afe3a..49b032df 100644 --- a/lib/appwrite/models/message.rb +++ b/lib/appwrite/models/message.rb @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "providerType" => "", "topics" => [], "users" => [], "targets" => [], "deliveredTotal" => 0, "data" => {}, "status" => "draft" }.merge(map) Message.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/message_list.rb b/lib/appwrite/models/message_list.rb index 50175444..d3930021 100644 --- a/lib/appwrite/models/message_list.rb +++ b/lib/appwrite/models/message_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "messages" => [] }.merge(map) MessageList.new( total: map["total"], messages: map["messages"].map { |it| Message.from(map: it) } diff --git a/lib/appwrite/models/mfa_challenge.rb b/lib/appwrite/models/mfa_challenge.rb index 6ba21fef..384f9031 100644 --- a/lib/appwrite/models/mfa_challenge.rb +++ b/lib/appwrite/models/mfa_challenge.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "expire" => "" }.merge(map) MfaChallenge.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/mfa_challenge_secret.rb b/lib/appwrite/models/mfa_challenge_secret.rb index ad8abbcd..36cb2e7d 100644 --- a/lib/appwrite/models/mfa_challenge_secret.rb +++ b/lib/appwrite/models/mfa_challenge_secret.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "expire" => "", "code" => "" }.merge(map) MfaChallengeSecret.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/mfa_factors.rb b/lib/appwrite/models/mfa_factors.rb index 55b58ca2..55db99ea 100644 --- a/lib/appwrite/models/mfa_factors.rb +++ b/lib/appwrite/models/mfa_factors.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "totp" => false, "phone" => false, "email" => false, "recoveryCode" => false, "custom" => false }.merge(map) MfaFactors.new( totp: map["totp"], phone: map["phone"], diff --git a/lib/appwrite/models/mfa_recovery_codes.rb b/lib/appwrite/models/mfa_recovery_codes.rb index 1fd53c11..c9097acb 100644 --- a/lib/appwrite/models/mfa_recovery_codes.rb +++ b/lib/appwrite/models/mfa_recovery_codes.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "recoveryCodes" => [] }.merge(map) MfaRecoveryCodes.new( recovery_codes: map["recoveryCodes"] ) diff --git a/lib/appwrite/models/mfa_type.rb b/lib/appwrite/models/mfa_type.rb index 0612dc2d..4a8c7482 100644 --- a/lib/appwrite/models/mfa_type.rb +++ b/lib/appwrite/models/mfa_type.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "secret" => "", "uri" => "" }.merge(map) MfaType.new( secret: map["secret"], uri: map["uri"] diff --git a/lib/appwrite/models/mock_number.rb b/lib/appwrite/models/mock_number.rb index 59d96f27..8bb41c9b 100644 --- a/lib/appwrite/models/mock_number.rb +++ b/lib/appwrite/models/mock_number.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "number" => "", "otp" => "", "$createdAt" => "", "$updatedAt" => "" }.merge(map) MockNumber.new( number: map["number"], otp: map["otp"], diff --git a/lib/appwrite/models/mock_number_list.rb b/lib/appwrite/models/mock_number_list.rb index 56a7fdd2..ca3a9af1 100644 --- a/lib/appwrite/models/mock_number_list.rb +++ b/lib/appwrite/models/mock_number_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "mockNumbers" => [] }.merge(map) MockNumberList.new( total: map["total"], mock_numbers: map["mockNumbers"].map { |it| MockNumber.from(map: it) } diff --git a/lib/appwrite/models/o_auth2_amazon.rb b/lib/appwrite/models/o_auth2_amazon.rb index 177ce121..1afa9f98 100644 --- a/lib/appwrite/models/o_auth2_amazon.rb +++ b/lib/appwrite/models/o_auth2_amazon.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Amazon.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_apple.rb b/lib/appwrite/models/o_auth2_apple.rb index f5949d06..ed1b5058 100644 --- a/lib/appwrite/models/o_auth2_apple.rb +++ b/lib/appwrite/models/o_auth2_apple.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "serviceId" => "", "keyId" => "", "teamId" => "", "p8File" => "", "nativeEnabled" => false, "nativeClientIds" => [] }.merge(map) OAuth2Apple.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_appwrite.rb b/lib/appwrite/models/o_auth2_appwrite.rb index c12a6b55..e9624285 100644 --- a/lib/appwrite/models/o_auth2_appwrite.rb +++ b/lib/appwrite/models/o_auth2_appwrite.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Appwrite.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_auth0.rb b/lib/appwrite/models/o_auth2_auth0.rb index e9cf3cb0..0625fe06 100644 --- a/lib/appwrite/models/o_auth2_auth0.rb +++ b/lib/appwrite/models/o_auth2_auth0.rb @@ -22,11 +22,12 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) @endpoint = endpoint end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [], "endpoint" => "" }.merge(map) OAuth2Auth0.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_authentik.rb b/lib/appwrite/models/o_auth2_authentik.rb index 81fc7ff8..643597f5 100644 --- a/lib/appwrite/models/o_auth2_authentik.rb +++ b/lib/appwrite/models/o_auth2_authentik.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "endpoint" => "" }.merge(map) OAuth2Authentik.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_autodesk.rb b/lib/appwrite/models/o_auth2_autodesk.rb index f260b12e..fa2a8d98 100644 --- a/lib/appwrite/models/o_auth2_autodesk.rb +++ b/lib/appwrite/models/o_auth2_autodesk.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Autodesk.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_bitbucket.rb b/lib/appwrite/models/o_auth2_bitbucket.rb index 44509504..f4686ebc 100644 --- a/lib/appwrite/models/o_auth2_bitbucket.rb +++ b/lib/appwrite/models/o_auth2_bitbucket.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "key" => "", "secret" => "" }.merge(map) OAuth2Bitbucket.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_bitly.rb b/lib/appwrite/models/o_auth2_bitly.rb index ad116ed0..a9efb469 100644 --- a/lib/appwrite/models/o_auth2_bitly.rb +++ b/lib/appwrite/models/o_auth2_bitly.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Bitly.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_box.rb b/lib/appwrite/models/o_auth2_box.rb index 7cdfedd0..e2aa2269 100644 --- a/lib/appwrite/models/o_auth2_box.rb +++ b/lib/appwrite/models/o_auth2_box.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Box.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_cloudflare.rb b/lib/appwrite/models/o_auth2_cloudflare.rb index 7f3e65bf..f0bc5549 100644 --- a/lib/appwrite/models/o_auth2_cloudflare.rb +++ b/lib/appwrite/models/o_auth2_cloudflare.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Cloudflare.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_dailymotion.rb b/lib/appwrite/models/o_auth2_dailymotion.rb index 31e10ed1..241d92c7 100644 --- a/lib/appwrite/models/o_auth2_dailymotion.rb +++ b/lib/appwrite/models/o_auth2_dailymotion.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "apiKey" => "", "apiSecret" => "" }.merge(map) OAuth2Dailymotion.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_discord.rb b/lib/appwrite/models/o_auth2_discord.rb index 5d7db0cb..972672bd 100644 --- a/lib/appwrite/models/o_auth2_discord.rb +++ b/lib/appwrite/models/o_auth2_discord.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [] }.merge(map) OAuth2Discord.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_disqus.rb b/lib/appwrite/models/o_auth2_disqus.rb index 2b8e4261..e1670515 100644 --- a/lib/appwrite/models/o_auth2_disqus.rb +++ b/lib/appwrite/models/o_auth2_disqus.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "publicKey" => "", "secretKey" => "" }.merge(map) OAuth2Disqus.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_dropbox.rb b/lib/appwrite/models/o_auth2_dropbox.rb index d5581312..d57c294d 100644 --- a/lib/appwrite/models/o_auth2_dropbox.rb +++ b/lib/appwrite/models/o_auth2_dropbox.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "appKey" => "", "appSecret" => "" }.merge(map) OAuth2Dropbox.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_etsy.rb b/lib/appwrite/models/o_auth2_etsy.rb index 87acab75..2af4595a 100644 --- a/lib/appwrite/models/o_auth2_etsy.rb +++ b/lib/appwrite/models/o_auth2_etsy.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "keyString" => "", "sharedSecret" => "" }.merge(map) OAuth2Etsy.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_facebook.rb b/lib/appwrite/models/o_auth2_facebook.rb index f42ab1e7..6a6206de 100644 --- a/lib/appwrite/models/o_auth2_facebook.rb +++ b/lib/appwrite/models/o_auth2_facebook.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "appId" => "", "appSecret" => "" }.merge(map) OAuth2Facebook.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_figma.rb b/lib/appwrite/models/o_auth2_figma.rb index 7da8c796..2470388c 100644 --- a/lib/appwrite/models/o_auth2_figma.rb +++ b/lib/appwrite/models/o_auth2_figma.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Figma.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_fusion_auth.rb b/lib/appwrite/models/o_auth2_fusion_auth.rb index 74e205e3..28bf8307 100644 --- a/lib/appwrite/models/o_auth2_fusion_auth.rb +++ b/lib/appwrite/models/o_auth2_fusion_auth.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "endpoint" => "" }.merge(map) OAuth2FusionAuth.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_github.rb b/lib/appwrite/models/o_auth2_github.rb index d46e1e38..66986a27 100644 --- a/lib/appwrite/models/o_auth2_github.rb +++ b/lib/appwrite/models/o_auth2_github.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [] }.merge(map) OAuth2Github.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_gitlab.rb b/lib/appwrite/models/o_auth2_gitlab.rb index 2f1d2237..5a7b7f5b 100644 --- a/lib/appwrite/models/o_auth2_gitlab.rb +++ b/lib/appwrite/models/o_auth2_gitlab.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "applicationId" => "", "secret" => "", "endpoint" => "" }.merge(map) OAuth2Gitlab.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_google.rb b/lib/appwrite/models/o_auth2_google.rb index b646c30d..be1959fd 100644 --- a/lib/appwrite/models/o_auth2_google.rb +++ b/lib/appwrite/models/o_auth2_google.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => ["consent"], "nativeEnabled" => false, "nativeClientIds" => [] }.merge(map) OAuth2Google.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_hugging_face.rb b/lib/appwrite/models/o_auth2_hugging_face.rb index c75e13cc..43430cb0 100644 --- a/lib/appwrite/models/o_auth2_hugging_face.rb +++ b/lib/appwrite/models/o_auth2_hugging_face.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2HuggingFace.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_keycloak.rb b/lib/appwrite/models/o_auth2_keycloak.rb index 6af51b90..3e432d14 100644 --- a/lib/appwrite/models/o_auth2_keycloak.rb +++ b/lib/appwrite/models/o_auth2_keycloak.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "endpoint" => "", "realmName" => "" }.merge(map) OAuth2Keycloak.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_kick.rb b/lib/appwrite/models/o_auth2_kick.rb index eb5c8092..1d764fa3 100644 --- a/lib/appwrite/models/o_auth2_kick.rb +++ b/lib/appwrite/models/o_auth2_kick.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Kick.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_linkedin.rb b/lib/appwrite/models/o_auth2_linkedin.rb index 8b91b062..bcac2a97 100644 --- a/lib/appwrite/models/o_auth2_linkedin.rb +++ b/lib/appwrite/models/o_auth2_linkedin.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "primaryClientSecret" => "" }.merge(map) OAuth2Linkedin.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_microsoft.rb b/lib/appwrite/models/o_auth2_microsoft.rb index 29c2cb1e..4525c54c 100644 --- a/lib/appwrite/models/o_auth2_microsoft.rb +++ b/lib/appwrite/models/o_auth2_microsoft.rb @@ -22,11 +22,12 @@ def initialize( @enabled = enabled @application_id = application_id @application_secret = application_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) @tenant = tenant end def self.from(map:) + map = { "$id" => "", "enabled" => false, "applicationId" => "", "applicationSecret" => "", "prompt" => [], "tenant" => "" }.merge(map) OAuth2Microsoft.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_notion.rb b/lib/appwrite/models/o_auth2_notion.rb index 3382c410..1869df5b 100644 --- a/lib/appwrite/models/o_auth2_notion.rb +++ b/lib/appwrite/models/o_auth2_notion.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "oauthClientId" => "", "oauthClientSecret" => "" }.merge(map) OAuth2Notion.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_oidc.rb b/lib/appwrite/models/o_auth2_oidc.rb index a034231b..a3cbee0e 100644 --- a/lib/appwrite/models/o_auth2_oidc.rb +++ b/lib/appwrite/models/o_auth2_oidc.rb @@ -7,11 +7,11 @@ class OAuth2Oidc attr_reader :enabled attr_reader :client_id attr_reader :client_secret + attr_reader :prompt attr_reader :well_known_url attr_reader :authorization_url attr_reader :token_url attr_reader :user_info_url - attr_reader :prompt attr_reader :max_age def initialize( @@ -19,36 +19,37 @@ def initialize( enabled:, client_id:, client_secret:, + prompt:, well_known_url:, authorization_url:, token_url:, user_info_url:, - prompt:, max_age: ) @id = id @enabled = enabled @client_id = client_id @client_secret = client_secret + @prompt = validate_prompt(prompt) @well_known_url = well_known_url @authorization_url = authorization_url @token_url = token_url @user_info_url = user_info_url - @prompt = validate_prompt(prompt) @max_age = max_age end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [], "wellKnownURL" => "", "authorizationURL" => "", "tokenURL" => "", "userInfoURL" => "" }.merge(map) OAuth2Oidc.new( id: map["$id"], enabled: map["enabled"], client_id: map["clientId"], client_secret: map["clientSecret"], + prompt: map["prompt"], well_known_url: map["wellKnownURL"], authorization_url: map["authorizationURL"], token_url: map["tokenURL"], user_info_url: map["userInfoURL"], - prompt: map["prompt"], max_age: map["maxAge"] ) end @@ -59,11 +60,11 @@ def to_map "enabled": @enabled, "clientId": @client_id, "clientSecret": @client_secret, + "prompt": @prompt, "wellKnownURL": @well_known_url, "authorizationURL": @authorization_url, "tokenURL": @token_url, "userInfoURL": @user_info_url, - "prompt": @prompt, "maxAge": @max_age } end diff --git a/lib/appwrite/models/o_auth2_okta.rb b/lib/appwrite/models/o_auth2_okta.rb index 11d5746f..4abfdd09 100644 --- a/lib/appwrite/models/o_auth2_okta.rb +++ b/lib/appwrite/models/o_auth2_okta.rb @@ -24,12 +24,13 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) @domain = domain @authorization_server_id = authorization_server_id end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [], "domain" => "", "authorizationServerId" => "" }.merge(map) OAuth2Okta.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_paypal.rb b/lib/appwrite/models/o_auth2_paypal.rb index 32263b46..27db8cdd 100644 --- a/lib/appwrite/models/o_auth2_paypal.rb +++ b/lib/appwrite/models/o_auth2_paypal.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "secretKey" => "" }.merge(map) OAuth2Paypal.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_podio.rb b/lib/appwrite/models/o_auth2_podio.rb index d1efea82..f25f60e2 100644 --- a/lib/appwrite/models/o_auth2_podio.rb +++ b/lib/appwrite/models/o_auth2_podio.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Podio.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_provider_list.rb b/lib/appwrite/models/o_auth2_provider_list.rb index 16bdbbaf..40596466 100644 --- a/lib/appwrite/models/o_auth2_provider_list.rb +++ b/lib/appwrite/models/o_auth2_provider_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "providers" => [] }.merge(map) OAuth2ProviderList.new( total: map["total"], providers: map["providers"] diff --git a/lib/appwrite/models/o_auth2_resend.rb b/lib/appwrite/models/o_auth2_resend.rb index 9a64087d..86084bde 100644 --- a/lib/appwrite/models/o_auth2_resend.rb +++ b/lib/appwrite/models/o_auth2_resend.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Resend.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_salesforce.rb b/lib/appwrite/models/o_auth2_salesforce.rb index 0cd7bc78..0a3ae31a 100644 --- a/lib/appwrite/models/o_auth2_salesforce.rb +++ b/lib/appwrite/models/o_auth2_salesforce.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @customer_key = customer_key @customer_secret = customer_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "customerKey" => "", "customerSecret" => "", "prompt" => [] }.merge(map) OAuth2Salesforce.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_slack.rb b/lib/appwrite/models/o_auth2_slack.rb index 209cc3b5..149cd400 100644 --- a/lib/appwrite/models/o_auth2_slack.rb +++ b/lib/appwrite/models/o_auth2_slack.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Slack.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_spotify.rb b/lib/appwrite/models/o_auth2_spotify.rb index 014d82dc..addf5467 100644 --- a/lib/appwrite/models/o_auth2_spotify.rb +++ b/lib/appwrite/models/o_auth2_spotify.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Spotify.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_stripe.rb b/lib/appwrite/models/o_auth2_stripe.rb index 66604406..4b580c06 100644 --- a/lib/appwrite/models/o_auth2_stripe.rb +++ b/lib/appwrite/models/o_auth2_stripe.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "apiSecretKey" => "" }.merge(map) OAuth2Stripe.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_tradeshift.rb b/lib/appwrite/models/o_auth2_tradeshift.rb index 749c666d..5099f337 100644 --- a/lib/appwrite/models/o_auth2_tradeshift.rb +++ b/lib/appwrite/models/o_auth2_tradeshift.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "oauth2ClientId" => "", "oauth2ClientSecret" => "" }.merge(map) OAuth2Tradeshift.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_twitch.rb b/lib/appwrite/models/o_auth2_twitch.rb index ac7fa8a1..b2f90f4e 100644 --- a/lib/appwrite/models/o_auth2_twitch.rb +++ b/lib/appwrite/models/o_auth2_twitch.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Twitch.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_word_press.rb b/lib/appwrite/models/o_auth2_word_press.rb index 3fab755c..9453b756 100644 --- a/lib/appwrite/models/o_auth2_word_press.rb +++ b/lib/appwrite/models/o_auth2_word_press.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2WordPress.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_x.rb b/lib/appwrite/models/o_auth2_x.rb index d2f771a4..55b32ea6 100644 --- a/lib/appwrite/models/o_auth2_x.rb +++ b/lib/appwrite/models/o_auth2_x.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "customerKey" => "", "secretKey" => "" }.merge(map) OAuth2X.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_yahoo.rb b/lib/appwrite/models/o_auth2_yahoo.rb index 13aea493..1d0819e1 100644 --- a/lib/appwrite/models/o_auth2_yahoo.rb +++ b/lib/appwrite/models/o_auth2_yahoo.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Yahoo.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_yandex.rb b/lib/appwrite/models/o_auth2_yandex.rb index 8373037e..102e0bf4 100644 --- a/lib/appwrite/models/o_auth2_yandex.rb +++ b/lib/appwrite/models/o_auth2_yandex.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Yandex.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_zoho.rb b/lib/appwrite/models/o_auth2_zoho.rb index 792da041..c7bb5db2 100644 --- a/lib/appwrite/models/o_auth2_zoho.rb +++ b/lib/appwrite/models/o_auth2_zoho.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [] }.merge(map) OAuth2Zoho.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_zoom.rb b/lib/appwrite/models/o_auth2_zoom.rb index d7b261ce..97617c2b 100644 --- a/lib/appwrite/models/o_auth2_zoom.rb +++ b/lib/appwrite/models/o_auth2_zoom.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Zoom.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/oauth2_approve.rb b/lib/appwrite/models/oauth2_approve.rb index 748c7880..32e7f309 100644 --- a/lib/appwrite/models/oauth2_approve.rb +++ b/lib/appwrite/models/oauth2_approve.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "redirectUrl" => "" }.merge(map) Oauth2Approve.new( redirect_url: map["redirectUrl"] ) diff --git a/lib/appwrite/models/oauth2_authorize.rb b/lib/appwrite/models/oauth2_authorize.rb index 99f35e8c..269932a6 100644 --- a/lib/appwrite/models/oauth2_authorize.rb +++ b/lib/appwrite/models/oauth2_authorize.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "grantId" => "", "redirectUrl" => "" }.merge(map) Oauth2Authorize.new( grant_id: map["grantId"], redirect_url: map["redirectUrl"] diff --git a/lib/appwrite/models/oauth2_consent.rb b/lib/appwrite/models/oauth2_consent.rb index af8f3ec0..f1080bca 100644 --- a/lib/appwrite/models/oauth2_consent.rb +++ b/lib/appwrite/models/oauth2_consent.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "appId" => "", "cimdUrl" => "", "scopes" => [], "resources" => [], "authorizationDetails" => "[]", "expire" => "" }.merge(map) Oauth2Consent.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/oauth2_consent_list.rb b/lib/appwrite/models/oauth2_consent_list.rb index a6ca3cea..7543e968 100644 --- a/lib/appwrite/models/oauth2_consent_list.rb +++ b/lib/appwrite/models/oauth2_consent_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "consents" => [] }.merge(map) Oauth2ConsentList.new( total: map["total"], consents: map["consents"].map { |it| Oauth2Consent.from(map: it) } diff --git a/lib/appwrite/models/oauth2_consent_token.rb b/lib/appwrite/models/oauth2_consent_token.rb index 6b1bc02a..bc01ac00 100644 --- a/lib/appwrite/models/oauth2_consent_token.rb +++ b/lib/appwrite/models/oauth2_consent_token.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "consentId" => "", "userId" => "", "appId" => "", "cimdUrl" => "", "scopes" => [], "resources" => [], "authorizationDetails" => "[]", "expire" => "" }.merge(map) Oauth2ConsentToken.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/oauth2_consent_token_list.rb b/lib/appwrite/models/oauth2_consent_token_list.rb index edf5aef9..efcc0a05 100644 --- a/lib/appwrite/models/oauth2_consent_token_list.rb +++ b/lib/appwrite/models/oauth2_consent_token_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "tokens" => [] }.merge(map) Oauth2ConsentTokenList.new( total: map["total"], tokens: map["tokens"].map { |it| Oauth2ConsentToken.from(map: it) } diff --git a/lib/appwrite/models/oauth2_device_authorization.rb b/lib/appwrite/models/oauth2_device_authorization.rb index 428970ac..86c07de1 100644 --- a/lib/appwrite/models/oauth2_device_authorization.rb +++ b/lib/appwrite/models/oauth2_device_authorization.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "device_code" => "", "user_code" => "", "verification_uri" => "", "verification_uri_complete" => "", "expires_in" => 0, "interval" => 0 }.merge(map) Oauth2DeviceAuthorization.new( device_code: map["device_code"], user_code: map["user_code"], diff --git a/lib/appwrite/models/oauth2_grant.rb b/lib/appwrite/models/oauth2_grant.rb index df5192bf..d94b15c5 100644 --- a/lib/appwrite/models/oauth2_grant.rb +++ b/lib/appwrite/models/oauth2_grant.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "appId" => "", "scopes" => [], "resources" => [], "authorizationDetails" => "[]", "prompt" => "", "redirectUri" => "", "authTime" => 0, "expire" => "" }.merge(map) Oauth2Grant.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/oauth2_organization.rb b/lib/appwrite/models/oauth2_organization.rb index b69fd0cb..70916f0e 100644 --- a/lib/appwrite/models/oauth2_organization.rb +++ b/lib/appwrite/models/oauth2_organization.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "" }.merge(map) Oauth2Organization.new( id: map["$id"] ) diff --git a/lib/appwrite/models/oauth2_organization_list.rb b/lib/appwrite/models/oauth2_organization_list.rb index 7921605a..1988d853 100644 --- a/lib/appwrite/models/oauth2_organization_list.rb +++ b/lib/appwrite/models/oauth2_organization_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "organizations" => [] }.merge(map) Oauth2OrganizationList.new( total: map["total"], organizations: map["organizations"].map { |it| Oauth2Organization.from(map: it) } diff --git a/lib/appwrite/models/oauth2_par.rb b/lib/appwrite/models/oauth2_par.rb index 18198dc6..17b3ee44 100644 --- a/lib/appwrite/models/oauth2_par.rb +++ b/lib/appwrite/models/oauth2_par.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "request_uri" => "", "expires_in" => 0 }.merge(map) Oauth2PAR.new( request_uri: map["request_uri"], expires_in: map["expires_in"] diff --git a/lib/appwrite/models/oauth2_project.rb b/lib/appwrite/models/oauth2_project.rb index 01b2531c..437421b6 100644 --- a/lib/appwrite/models/oauth2_project.rb +++ b/lib/appwrite/models/oauth2_project.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "region" => "", "endpoint" => "" }.merge(map) Oauth2Project.new( id: map["$id"], region: map["region"], diff --git a/lib/appwrite/models/oauth2_project_list.rb b/lib/appwrite/models/oauth2_project_list.rb index a98a6769..d6338e3c 100644 --- a/lib/appwrite/models/oauth2_project_list.rb +++ b/lib/appwrite/models/oauth2_project_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "projects" => [] }.merge(map) Oauth2ProjectList.new( total: map["total"], projects: map["projects"].map { |it| Oauth2Project.from(map: it) } diff --git a/lib/appwrite/models/oauth2_reject.rb b/lib/appwrite/models/oauth2_reject.rb index 614546e0..29325140 100644 --- a/lib/appwrite/models/oauth2_reject.rb +++ b/lib/appwrite/models/oauth2_reject.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "redirectUrl" => "" }.merge(map) Oauth2Reject.new( redirect_url: map["redirectUrl"] ) diff --git a/lib/appwrite/models/oauth2_token.rb b/lib/appwrite/models/oauth2_token.rb index 59ffd23f..19511db3 100644 --- a/lib/appwrite/models/oauth2_token.rb +++ b/lib/appwrite/models/oauth2_token.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "access_token" => "", "token_type" => "Bearer", "expires_in" => 0, "refresh_token" => "", "scope" => "" }.merge(map) Oauth2Token.new( access_token: map["access_token"], token_type: map["token_type"], diff --git a/lib/appwrite/models/organization.rb b/lib/appwrite/models/organization.rb index aa53b68a..3ef73281 100644 --- a/lib/appwrite/models/organization.rb +++ b/lib/appwrite/models/organization.rb @@ -114,6 +114,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "total" => 0, "budgetAlerts" => [75], "billingPlan" => "tier-0", "billingPlanId" => "tier-0", "billingEmail" => "", "status" => "draft", "markedForDeletion" => false, "platform" => "appwrite", "projects" => [] }.merge(map) Organization.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/passkey.rb b/lib/appwrite/models/passkey.rb index 5098b87b..8cea8129 100644 --- a/lib/appwrite/models/passkey.rb +++ b/lib/appwrite/models/passkey.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "accessedAt" => "" }.merge(map) Passkey.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/passkey_challenge.rb b/lib/appwrite/models/passkey_challenge.rb index b9751184..22f1774c 100644 --- a/lib/appwrite/models/passkey_challenge.rb +++ b/lib/appwrite/models/passkey_challenge.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "passkeyId" => "", "expire" => "", "publicKey" => {} }.merge(map) PasskeyChallenge.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/passkey_list.rb b/lib/appwrite/models/passkey_list.rb index 86a515b7..dffca579 100644 --- a/lib/appwrite/models/passkey_list.rb +++ b/lib/appwrite/models/passkey_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "passkeys" => [] }.merge(map) PasskeyList.new( total: map["total"], passkeys: map["passkeys"].map { |it| Passkey.from(map: it) } diff --git a/lib/appwrite/models/phone.rb b/lib/appwrite/models/phone.rb index 769ea1be..c4d5137c 100644 --- a/lib/appwrite/models/phone.rb +++ b/lib/appwrite/models/phone.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "code" => "", "countryCode" => "", "countryName" => "" }.merge(map) Phone.new( code: map["code"], country_code: map["countryCode"], diff --git a/lib/appwrite/models/phone_list.rb b/lib/appwrite/models/phone_list.rb index d6ad3e14..fea0fea8 100644 --- a/lib/appwrite/models/phone_list.rb +++ b/lib/appwrite/models/phone_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "phones" => [] }.merge(map) PhoneList.new( total: map["total"], phones: map["phones"].map { |it| Phone.from(map: it) } diff --git a/lib/appwrite/models/platform_android.rb b/lib/appwrite/models/platform_android.rb index da5ba79b..3559270e 100644 --- a/lib/appwrite/models/platform_android.rb +++ b/lib/appwrite/models/platform_android.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "applicationId" => "", "fingerprints" => [] }.merge(map) PlatformAndroid.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_apple.rb b/lib/appwrite/models/platform_apple.rb index 06f7aeea..fa95f584 100644 --- a/lib/appwrite/models/platform_apple.rb +++ b/lib/appwrite/models/platform_apple.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "bundleIdentifier" => "" }.merge(map) PlatformApple.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_linux.rb b/lib/appwrite/models/platform_linux.rb index 1442fd5e..a35bc2ca 100644 --- a/lib/appwrite/models/platform_linux.rb +++ b/lib/appwrite/models/platform_linux.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "packageName" => "" }.merge(map) PlatformLinux.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_list.rb b/lib/appwrite/models/platform_list.rb index a51bb20e..c18d4b33 100644 --- a/lib/appwrite/models/platform_list.rb +++ b/lib/appwrite/models/platform_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "platforms" => [] }.merge(map) PlatformList.new( total: map["total"], platforms: map["platforms"] diff --git a/lib/appwrite/models/platform_web.rb b/lib/appwrite/models/platform_web.rb index 8e84519d..a3925665 100644 --- a/lib/appwrite/models/platform_web.rb +++ b/lib/appwrite/models/platform_web.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "hostname" => "" }.merge(map) PlatformWeb.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_windows.rb b/lib/appwrite/models/platform_windows.rb index 560f44d4..07d1e9d5 100644 --- a/lib/appwrite/models/platform_windows.rb +++ b/lib/appwrite/models/platform_windows.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "packageIdentifierName" => "" }.merge(map) PlatformWindows.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/policy_deny_aliased_email.rb b/lib/appwrite/models/policy_deny_aliased_email.rb index f7b755ae..1a05ce5d 100644 --- a/lib/appwrite/models/policy_deny_aliased_email.rb +++ b/lib/appwrite/models/policy_deny_aliased_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyAliasedEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_deny_corporate_email.rb b/lib/appwrite/models/policy_deny_corporate_email.rb index 4bdf38ae..3680ef40 100644 --- a/lib/appwrite/models/policy_deny_corporate_email.rb +++ b/lib/appwrite/models/policy_deny_corporate_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyCorporateEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_deny_disposable_email.rb b/lib/appwrite/models/policy_deny_disposable_email.rb index 23393bea..f3073750 100644 --- a/lib/appwrite/models/policy_deny_disposable_email.rb +++ b/lib/appwrite/models/policy_deny_disposable_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyDisposableEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_deny_free_email.rb b/lib/appwrite/models/policy_deny_free_email.rb index 766573bb..75bca6f0 100644 --- a/lib/appwrite/models/policy_deny_free_email.rb +++ b/lib/appwrite/models/policy_deny_free_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyFreeEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_list.rb b/lib/appwrite/models/policy_list.rb index 077c62f5..7c5be92c 100644 --- a/lib/appwrite/models/policy_list.rb +++ b/lib/appwrite/models/policy_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "policies" => [] }.merge(map) PolicyList.new( total: map["total"], policies: map["policies"] diff --git a/lib/appwrite/models/policy_membership_privacy.rb b/lib/appwrite/models/policy_membership_privacy.rb index 9fa040f1..2a1a56a4 100644 --- a/lib/appwrite/models/policy_membership_privacy.rb +++ b/lib/appwrite/models/policy_membership_privacy.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "userId" => false, "userEmail" => false, "userPhone" => false, "userName" => false, "userMFA" => false, "userAccessedAt" => false }.merge(map) PolicyMembershipPrivacy.new( id: map["$id"], user_id: map["userId"], diff --git a/lib/appwrite/models/policy_mfa_factors.rb b/lib/appwrite/models/policy_mfa_factors.rb index e49890a8..601ef66d 100644 --- a/lib/appwrite/models/policy_mfa_factors.rb +++ b/lib/appwrite/models/policy_mfa_factors.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "totp" => true, "email" => true, "phone" => true, "custom" => false }.merge(map) PolicyMfaFactors.new( id: map["$id"], totp: map["totp"], diff --git a/lib/appwrite/models/policy_passkey.rb b/lib/appwrite/models/policy_passkey.rb index f9cb6701..62bced03 100644 --- a/lib/appwrite/models/policy_passkey.rb +++ b/lib/appwrite/models/policy_passkey.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "rpId" => "", "origins" => [] }.merge(map) PolicyPasskey.new( id: map["$id"], rp_id: map["rpId"], diff --git a/lib/appwrite/models/policy_password_dictionary.rb b/lib/appwrite/models/policy_password_dictionary.rb index 38423bc4..b72d0caa 100644 --- a/lib/appwrite/models/policy_password_dictionary.rb +++ b/lib/appwrite/models/policy_password_dictionary.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyPasswordDictionary.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_password_history.rb b/lib/appwrite/models/policy_password_history.rb index e2d4b842..f5253d15 100644 --- a/lib/appwrite/models/policy_password_history.rb +++ b/lib/appwrite/models/policy_password_history.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "total" => 0 }.merge(map) PolicyPasswordHistory.new( id: map["$id"], total: map["total"] diff --git a/lib/appwrite/models/policy_password_personal_data.rb b/lib/appwrite/models/policy_password_personal_data.rb index 7e2c290e..2be97bd8 100644 --- a/lib/appwrite/models/policy_password_personal_data.rb +++ b/lib/appwrite/models/policy_password_personal_data.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyPasswordPersonalData.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_password_strength.rb b/lib/appwrite/models/policy_password_strength.rb index c2bf28fb..1240c6a0 100644 --- a/lib/appwrite/models/policy_password_strength.rb +++ b/lib/appwrite/models/policy_password_strength.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "min" => 8, "uppercase" => false, "lowercase" => false, "number" => false, "symbols" => false }.merge(map) PolicyPasswordStrength.new( id: map["$id"], min: map["min"], diff --git a/lib/appwrite/models/policy_session_alert.rb b/lib/appwrite/models/policy_session_alert.rb index 74ee3fa2..7ef6a816 100644 --- a/lib/appwrite/models/policy_session_alert.rb +++ b/lib/appwrite/models/policy_session_alert.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicySessionAlert.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_session_duration.rb b/lib/appwrite/models/policy_session_duration.rb index f23f26e9..2928b255 100644 --- a/lib/appwrite/models/policy_session_duration.rb +++ b/lib/appwrite/models/policy_session_duration.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "duration" => 31536000 }.merge(map) PolicySessionDuration.new( id: map["$id"], duration: map["duration"] diff --git a/lib/appwrite/models/policy_session_invalidation.rb b/lib/appwrite/models/policy_session_invalidation.rb index 4c7b0a2e..6ec72c3b 100644 --- a/lib/appwrite/models/policy_session_invalidation.rb +++ b/lib/appwrite/models/policy_session_invalidation.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => true }.merge(map) PolicySessionInvalidation.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_session_limit.rb b/lib/appwrite/models/policy_session_limit.rb index 2c3783d8..193d81b5 100644 --- a/lib/appwrite/models/policy_session_limit.rb +++ b/lib/appwrite/models/policy_session_limit.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "total" => 0 }.merge(map) PolicySessionLimit.new( id: map["$id"], total: map["total"] diff --git a/lib/appwrite/models/policy_user_limit.rb b/lib/appwrite/models/policy_user_limit.rb index b5554c19..1275753d 100644 --- a/lib/appwrite/models/policy_user_limit.rb +++ b/lib/appwrite/models/policy_user_limit.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "total" => 0 }.merge(map) PolicyUserLimit.new( id: map["$id"], total: map["total"] diff --git a/lib/appwrite/models/postgres_extension.rb b/lib/appwrite/models/postgres_extension.rb index 6ae09339..e1c5f081 100644 --- a/lib/appwrite/models/postgres_extension.rb +++ b/lib/appwrite/models/postgres_extension.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "name" => "", "description" => "", "category" => "" }.merge(map) PostgresExtension.new( key: map["key"], name: map["name"], diff --git a/lib/appwrite/models/presence.rb b/lib/appwrite/models/presence.rb index dabfb838..577da3cc 100644 --- a/lib/appwrite/models/presence.rb +++ b/lib/appwrite/models/presence.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "userId" => "", "source" => "" }.merge(map) Presence.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/presence_list.rb b/lib/appwrite/models/presence_list.rb index 01fa5bcb..b43ba834 100644 --- a/lib/appwrite/models/presence_list.rb +++ b/lib/appwrite/models/presence_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "presences" => [] }.merge(map) PresenceList.new( total: map["total"], presences: map["presences"].map { |it| Presence.from(map: it) } diff --git a/lib/appwrite/models/program.rb b/lib/appwrite/models/program.rb index db9215e1..7705670c 100644 --- a/lib/appwrite/models/program.rb +++ b/lib/appwrite/models/program.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "title" => "", "description" => "", "tag" => "", "icon" => "", "url" => "", "active" => true, "external" => true, "billingPlanId" => "" }.merge(map) Program.new( id: map["$id"], title: map["title"], diff --git a/lib/appwrite/models/project.rb b/lib/appwrite/models/project.rb index b03fcbc6..3af3e1dd 100644 --- a/lib/appwrite/models/project.rb +++ b/lib/appwrite/models/project.rb @@ -9,7 +9,6 @@ class Project attr_reader :name attr_reader :team_id attr_reader :region - attr_reader :dev_keys attr_reader :smtp_enabled attr_reader :smtp_sender_name attr_reader :smtp_sender_email @@ -60,7 +59,6 @@ def initialize( name:, team_id:, region:, - dev_keys:, smtp_enabled:, smtp_sender_name:, smtp_sender_email:, @@ -88,20 +86,20 @@ def initialize( mcp_accessed_at:, o_auth2_server_enabled:, o_auth2_server_authorization_url:, - o_auth2_server_scopes:, - o_auth2_server_default_scopes:, - o_auth2_server_installation_scopes:, - o_auth2_server_authorization_details_types:, - o_auth2_server_access_token_duration:, - 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_scopes: [], + o_auth2_server_default_scopes: [], + o_auth2_server_installation_scopes: [], + o_auth2_server_authorization_details_types: [], + o_auth2_server_access_token_duration: 0, + o_auth2_server_refresh_token_duration: 0, + o_auth2_server_public_access_token_duration: 0, + o_auth2_server_public_refresh_token_duration: 0, + o_auth2_server_installation_access_token_duration: 0, o_auth2_server_confidential_pkce:, o_auth2_server_verification_url:, - o_auth2_server_user_code_length:, - o_auth2_server_user_code_format:, - o_auth2_server_device_code_duration:, + o_auth2_server_user_code_length: 8, + o_auth2_server_user_code_format: "alphanumeric", + o_auth2_server_device_code_duration: 600, o_auth2_server_discovery_url: ) @id = id @@ -110,7 +108,6 @@ def initialize( @name = name @team_id = team_id @region = region - @dev_keys = dev_keys @smtp_enabled = smtp_enabled @smtp_sender_name = smtp_sender_name @smtp_sender_email = smtp_sender_email @@ -156,6 +153,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "teamId" => "", "region" => "fra", "smtpEnabled" => false, "smtpSenderName" => "", "smtpSenderEmail" => "", "smtpReplyToName" => "", "smtpReplyToEmail" => "", "smtpHost" => "", "smtpPort" => 0, "smtpUsername" => "", "smtpPassword" => "", "smtpSecure" => "", "pingCount" => 0, "pingedAt" => "", "labels" => [], "status" => "active", "onboarding" => {}, "authMethods" => [], "services" => [], "protocols" => [], "blocks" => [], "consoleAccessedAt" => "" }.merge(map) Project.new( id: map["$id"], created_at: map["$createdAt"], @@ -163,7 +161,6 @@ def self.from(map:) name: map["name"], team_id: map["teamId"], region: map["region"], - dev_keys: map["devKeys"].map { |it| DevKey.from(map: it) }, smtp_enabled: map["smtpEnabled"], smtp_sender_name: map["smtpSenderName"], smtp_sender_email: map["smtpSenderEmail"], @@ -217,7 +214,6 @@ def to_map "name": @name, "teamId": @team_id, "region": @region, - "devKeys": @dev_keys.map { |it| it.to_map }, "smtpEnabled": @smtp_enabled, "smtpSenderName": @smtp_sender_name, "smtpSenderEmail": @smtp_sender_email, diff --git a/lib/appwrite/models/project_auth_method.rb b/lib/appwrite/models/project_auth_method.rb index 98c67156..23162ba9 100644 --- a/lib/appwrite/models/project_auth_method.rb +++ b/lib/appwrite/models/project_auth_method.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => true }.merge(map) ProjectAuthMethod.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/project_list.rb b/lib/appwrite/models/project_list.rb index 552309a5..f2fd282a 100644 --- a/lib/appwrite/models/project_list.rb +++ b/lib/appwrite/models/project_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "projects" => [] }.merge(map) ProjectList.new( total: map["total"], projects: map["projects"].map { |it| Project.from(map: it) } diff --git a/lib/appwrite/models/project_protocol.rb b/lib/appwrite/models/project_protocol.rb index 58448214..a3071c87 100644 --- a/lib/appwrite/models/project_protocol.rb +++ b/lib/appwrite/models/project_protocol.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => true }.merge(map) ProjectProtocol.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/project_service.rb b/lib/appwrite/models/project_service.rb index 128c31b0..a4ea7343 100644 --- a/lib/appwrite/models/project_service.rb +++ b/lib/appwrite/models/project_service.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => true }.merge(map) ProjectService.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/provider.rb b/lib/appwrite/models/provider.rb index 80d6c956..90a53b7c 100644 --- a/lib/appwrite/models/provider.rb +++ b/lib/appwrite/models/provider.rb @@ -22,7 +22,7 @@ def initialize( enabled:, type:, credentials:, - options: + options: {} ) @id = id @created_at = created_at @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "provider" => "", "enabled" => true, "type" => "", "credentials" => {} }.merge(map) Provider.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/provider_list.rb b/lib/appwrite/models/provider_list.rb index 32f7da98..46909a15 100644 --- a/lib/appwrite/models/provider_list.rb +++ b/lib/appwrite/models/provider_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "providers" => [] }.merge(map) ProviderList.new( total: map["total"], providers: map["providers"].map { |it| Provider.from(map: it) } diff --git a/lib/appwrite/models/proxy_invalidation.rb b/lib/appwrite/models/proxy_invalidation.rb index 584669ac..872f90e6 100644 --- a/lib/appwrite/models/proxy_invalidation.rb +++ b/lib/appwrite/models/proxy_invalidation.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "domain" => "", "type" => "", "reference" => "", "status" => "" }.merge(map) ProxyInvalidation.new( domain: map["domain"], type: map["type"], diff --git a/lib/appwrite/models/proxy_rule.rb b/lib/appwrite/models/proxy_rule.rb index e37a6e6d..b8ac11c1 100644 --- a/lib/appwrite/models/proxy_rule.rb +++ b/lib/appwrite/models/proxy_rule.rb @@ -54,6 +54,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "domain" => "", "type" => "", "trigger" => "", "redirectUrl" => "", "redirectStatusCode" => 301, "deploymentId" => "", "deploymentResourceId" => "", "deploymentVcsProviderBranch" => "", "status" => "unverified", "logs" => "" }.merge(map) ProxyRule.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/proxy_rule_list.rb b/lib/appwrite/models/proxy_rule_list.rb index 24f99239..3f324ae8 100644 --- a/lib/appwrite/models/proxy_rule_list.rb +++ b/lib/appwrite/models/proxy_rule_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "rules" => [] }.merge(map) ProxyRuleList.new( total: map["total"], rules: map["rules"].map { |it| ProxyRule.from(map: it) } diff --git a/lib/appwrite/models/report.rb b/lib/appwrite/models/report.rb index b3912319..e39bde63 100644 --- a/lib/appwrite/models/report.rb +++ b/lib/appwrite/models/report.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "type" => "", "title" => "", "summary" => "", "targetType" => "", "target" => "", "categories" => [], "insights" => [] }.merge(map) Report.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/report_list.rb b/lib/appwrite/models/report_list.rb index 8cdd69a0..40a7cee2 100644 --- a/lib/appwrite/models/report_list.rb +++ b/lib/appwrite/models/report_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "reports" => [] }.merge(map) ReportList.new( total: map["total"], reports: map["reports"].map { |it| Report.from(map: it) } diff --git a/lib/appwrite/models/resource_token.rb b/lib/appwrite/models/resource_token.rb index 61c2b49e..a5d39ace 100644 --- a/lib/appwrite/models/resource_token.rb +++ b/lib/appwrite/models/resource_token.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "resourceId" => "", "resourceType" => "", "expire" => "", "secret" => "", "accessedAt" => "" }.merge(map) ResourceToken.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/resource_token_list.rb b/lib/appwrite/models/resource_token_list.rb index 928b7825..a07536c6 100644 --- a/lib/appwrite/models/resource_token_list.rb +++ b/lib/appwrite/models/resource_token_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "tokens" => [] }.merge(map) ResourceTokenList.new( total: map["total"], tokens: map["tokens"].map { |it| ResourceToken.from(map: it) } diff --git a/lib/appwrite/models/row.rb b/lib/appwrite/models/row.rb index c19c0445..2407b2ca 100644 --- a/lib/appwrite/models/row.rb +++ b/lib/appwrite/models/row.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$sequence" => "", "$tableId" => "", "$databaseId" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [] }.merge(map) Row.new( id: map["$id"], sequence: map["$sequence"], diff --git a/lib/appwrite/models/row_list.rb b/lib/appwrite/models/row_list.rb index debd9e50..55bcab78 100644 --- a/lib/appwrite/models/row_list.rb +++ b/lib/appwrite/models/row_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "rows" => [] }.merge(map) RowList.new( total: map["total"], rows: map["rows"].map { |it| Row.from(map: it) } diff --git a/lib/appwrite/models/runtime.rb b/lib/appwrite/models/runtime.rb index 4a09aa27..840663d4 100644 --- a/lib/appwrite/models/runtime.rb +++ b/lib/appwrite/models/runtime.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "key" => "", "name" => "", "version" => "", "base" => "", "image" => "", "logo" => "", "supports" => [] }.merge(map) Runtime.new( id: map["$id"], key: map["key"], diff --git a/lib/appwrite/models/runtime_list.rb b/lib/appwrite/models/runtime_list.rb index 5b69b4a6..018a5bf6 100644 --- a/lib/appwrite/models/runtime_list.rb +++ b/lib/appwrite/models/runtime_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "runtimes" => [] }.merge(map) RuntimeList.new( total: map["total"], runtimes: map["runtimes"].map { |it| Runtime.from(map: it) } diff --git a/lib/appwrite/models/session.rb b/lib/appwrite/models/session.rb index 762ee427..0777f369 100644 --- a/lib/appwrite/models/session.rb +++ b/lib/appwrite/models/session.rb @@ -96,6 +96,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "expire" => "", "provider" => "", "providerUid" => "", "providerAccessToken" => "", "providerAccessTokenExpiry" => "", "providerRefreshToken" => "", "ip" => "", "osCode" => "", "osName" => "", "osVersion" => "", "clientType" => "", "clientCode" => "", "clientName" => "", "clientVersion" => "", "clientEngine" => "", "clientEngineVersion" => "", "deviceName" => "", "deviceBrand" => "", "deviceModel" => "", "countryCode" => "", "countryName" => "", "current" => false, "factors" => [], "secret" => "", "mfaUpdatedAt" => "" }.merge(map) Session.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/session_list.rb b/lib/appwrite/models/session_list.rb index 320cefec..b55a7b94 100644 --- a/lib/appwrite/models/session_list.rb +++ b/lib/appwrite/models/session_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "sessions" => [] }.merge(map) SessionList.new( total: map["total"], sessions: map["sessions"].map { |it| Session.from(map: it) } diff --git a/lib/appwrite/models/site.rb b/lib/appwrite/models/site.rb index 94e80f00..60300827 100644 --- a/lib/appwrite/models/site.rb +++ b/lib/appwrite/models/site.rb @@ -114,6 +114,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "enabled" => true, "live" => true, "logging" => true, "framework" => "", "deploymentRetention" => 0, "deploymentId" => "", "deploymentCreatedAt" => "", "deploymentScreenshotLight" => "", "deploymentScreenshotDark" => "", "latestDeploymentId" => "", "latestDeploymentCreatedAt" => "", "latestDeploymentStatus" => "", "scopes" => [], "vars" => [], "timeout" => 15, "installCommand" => "", "buildCommand" => "", "startCommand" => "", "outputDirectory" => "", "installationId" => "", "providerRepositoryId" => "", "providerBranch" => "", "providerRootDirectory" => "", "providerSilentMode" => false, "providerBranches" => [], "providerPaths" => [], "buildSpecification" => "s-1vcpu-512mb", "runtimeSpecification" => "s-1vcpu-512mb", "buildRuntime" => "" }.merge(map) Site.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/site_list.rb b/lib/appwrite/models/site_list.rb index 51fb319d..f9537cc7 100644 --- a/lib/appwrite/models/site_list.rb +++ b/lib/appwrite/models/site_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "sites" => [] }.merge(map) SiteList.new( total: map["total"], sites: map["sites"].map { |it| Site.from(map: it) } diff --git a/lib/appwrite/models/specification.rb b/lib/appwrite/models/specification.rb index e9ff5467..b8606f25 100644 --- a/lib/appwrite/models/specification.rb +++ b/lib/appwrite/models/specification.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "memory" => 0, "cpus" => 0, "enabled" => false, "slug" => "" }.merge(map) Specification.new( memory: map["memory"], cpus: map["cpus"], diff --git a/lib/appwrite/models/specification_list.rb b/lib/appwrite/models/specification_list.rb index 8212053d..f79e4e31 100644 --- a/lib/appwrite/models/specification_list.rb +++ b/lib/appwrite/models/specification_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "specifications" => [] }.merge(map) SpecificationList.new( total: map["total"], specifications: map["specifications"].map { |it| Specification.from(map: it) } diff --git a/lib/appwrite/models/subscriber.rb b/lib/appwrite/models/subscriber.rb index 318baaab..b2e07da3 100644 --- a/lib/appwrite/models/subscriber.rb +++ b/lib/appwrite/models/subscriber.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "targetId" => "", "userId" => "", "userName" => "", "topicId" => "", "providerType" => "" }.merge(map) Subscriber.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/subscriber_list.rb b/lib/appwrite/models/subscriber_list.rb index 01373385..904bf7d0 100644 --- a/lib/appwrite/models/subscriber_list.rb +++ b/lib/appwrite/models/subscriber_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "subscribers" => [] }.merge(map) SubscriberList.new( total: map["total"], subscribers: map["subscribers"].map { |it| Subscriber.from(map: it) } diff --git a/lib/appwrite/models/table.rb b/lib/appwrite/models/table.rb index 2a7e4649..69851a39 100644 --- a/lib/appwrite/models/table.rb +++ b/lib/appwrite/models/table.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "databaseId" => "", "name" => "", "enabled" => true, "rowSecurity" => false, "columns" => [], "indexes" => [], "bytesMax" => 0, "bytesUsed" => 0 }.merge(map) Table.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/table_list.rb b/lib/appwrite/models/table_list.rb index 034d7fb3..98d96311 100644 --- a/lib/appwrite/models/table_list.rb +++ b/lib/appwrite/models/table_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "tables" => [] }.merge(map) TableList.new( total: map["total"], tables: map["tables"].map { |it| Table.from(map: it) } diff --git a/lib/appwrite/models/target.rb b/lib/appwrite/models/target.rb index 56e90755..8d11a1fe 100644 --- a/lib/appwrite/models/target.rb +++ b/lib/appwrite/models/target.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "userId" => "", "providerType" => "", "identifier" => "", "expired" => false }.merge(map) Target.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/target_list.rb b/lib/appwrite/models/target_list.rb index 9ccd7705..1c7fe0e8 100644 --- a/lib/appwrite/models/target_list.rb +++ b/lib/appwrite/models/target_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "targets" => [] }.merge(map) TargetList.new( total: map["total"], targets: map["targets"].map { |it| Target.from(map: it) } diff --git a/lib/appwrite/models/team.rb b/lib/appwrite/models/team.rb index d08f183f..06bcaf72 100644 --- a/lib/appwrite/models/team.rb +++ b/lib/appwrite/models/team.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "total" => 0 }.merge(map) Team.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/team_list.rb b/lib/appwrite/models/team_list.rb index e02efc9c..01300672 100644 --- a/lib/appwrite/models/team_list.rb +++ b/lib/appwrite/models/team_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "teams" => [] }.merge(map) TeamList.new( total: map["total"], teams: map["teams"].map { |it| Team.from(map: it) } diff --git a/lib/appwrite/models/token.rb b/lib/appwrite/models/token.rb index b3f539af..bf6c51a9 100644 --- a/lib/appwrite/models/token.rb +++ b/lib/appwrite/models/token.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "secret" => "", "expire" => "", "phrase" => "" }.merge(map) Token.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/token_secret.rb b/lib/appwrite/models/token_secret.rb index 4744532f..31ef131b 100644 --- a/lib/appwrite/models/token_secret.rb +++ b/lib/appwrite/models/token_secret.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "secret" => "", "expire" => "", "phrase" => "" }.merge(map) TokenSecret.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/topic.rb b/lib/appwrite/models/topic.rb index 247284d8..9f7c6a6c 100644 --- a/lib/appwrite/models/topic.rb +++ b/lib/appwrite/models/topic.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "emailTotal" => 0, "smsTotal" => 0, "pushTotal" => 0, "subscribe" => ["users"] }.merge(map) Topic.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/topic_list.rb b/lib/appwrite/models/topic_list.rb index e1b8c6d0..9542c588 100644 --- a/lib/appwrite/models/topic_list.rb +++ b/lib/appwrite/models/topic_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "topics" => [] }.merge(map) TopicList.new( total: map["total"], topics: map["topics"].map { |it| Topic.from(map: it) } diff --git a/lib/appwrite/models/transaction.rb b/lib/appwrite/models/transaction.rb index 481c25c9..e35a80fa 100644 --- a/lib/appwrite/models/transaction.rb +++ b/lib/appwrite/models/transaction.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "status" => "pending", "operations" => 0, "expiresAt" => "" }.merge(map) Transaction.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/transaction_list.rb b/lib/appwrite/models/transaction_list.rb index 17234abd..0db83c65 100644 --- a/lib/appwrite/models/transaction_list.rb +++ b/lib/appwrite/models/transaction_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "transactions" => [] }.merge(map) TransactionList.new( total: map["total"], transactions: map["transactions"].map { |it| Transaction.from(map: it) } diff --git a/lib/appwrite/models/usage_billing_plan.rb b/lib/appwrite/models/usage_billing_plan.rb index be1d81f6..0a181abb 100644 --- a/lib/appwrite/models/usage_billing_plan.rb +++ b/lib/appwrite/models/usage_billing_plan.rb @@ -43,32 +43,32 @@ def initialize( def self.from(map:) UsageBillingPlan.new( - bandwidth: AdditionalResource.from(map: map["bandwidth"]), - executions: AdditionalResource.from(map: map["executions"]), + bandwidth: map["bandwidth"].nil? ? nil : AdditionalResource.from(map: map["bandwidth"]), + executions: map["executions"].nil? ? nil : AdditionalResource.from(map: map["executions"]), member: map["member"].nil? ? nil : AdditionalResource.from(map: map["member"]), - realtime: AdditionalResource.from(map: map["realtime"]), - realtime_messages: AdditionalResource.from(map: map["realtimeMessages"]), + realtime: map["realtime"].nil? ? nil : AdditionalResource.from(map: map["realtime"]), + realtime_messages: map["realtimeMessages"].nil? ? nil : AdditionalResource.from(map: map["realtimeMessages"]), realtime_bandwidth: map["realtimeBandwidth"].nil? ? nil : AdditionalResource.from(map: map["realtimeBandwidth"]), - storage: AdditionalResource.from(map: map["storage"]), - users: AdditionalResource.from(map: map["users"]), - gb_hours: AdditionalResource.from(map: map["GBHours"]), - image_transformations: AdditionalResource.from(map: map["imageTransformations"]), + storage: map["storage"].nil? ? nil : AdditionalResource.from(map: map["storage"]), + users: map["users"].nil? ? nil : AdditionalResource.from(map: map["users"]), + gb_hours: map["GBHours"].nil? ? nil : AdditionalResource.from(map: map["GBHours"]), + image_transformations: map["imageTransformations"].nil? ? nil : AdditionalResource.from(map: map["imageTransformations"]), credits: map["credits"].nil? ? nil : AdditionalResource.from(map: map["credits"]) ) end def to_map { - "bandwidth": @bandwidth.to_map, - "executions": @executions.to_map, + "bandwidth": @bandwidth&.to_map, + "executions": @executions&.to_map, "member": @member&.to_map, - "realtime": @realtime.to_map, - "realtimeMessages": @realtime_messages.to_map, + "realtime": @realtime&.to_map, + "realtimeMessages": @realtime_messages&.to_map, "realtimeBandwidth": @realtime_bandwidth&.to_map, - "storage": @storage.to_map, - "users": @users.to_map, - "GBHours": @gb_hours.to_map, - "imageTransformations": @image_transformations.to_map, + "storage": @storage&.to_map, + "users": @users&.to_map, + "GBHours": @gb_hours&.to_map, + "imageTransformations": @image_transformations&.to_map, "credits": @credits&.to_map } end diff --git a/lib/appwrite/models/user.rb b/lib/appwrite/models/user.rb index 9586ee8c..240a4f11 100644 --- a/lib/appwrite/models/user.rb +++ b/lib/appwrite/models/user.rb @@ -90,6 +90,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "registration" => "", "status" => true, "labels" => [], "passwordUpdate" => "", "email" => "", "phone" => "", "emailVerification" => false, "phoneVerification" => false, "mfa" => false, "targets" => [], "accessedAt" => "" }.merge(map) User.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/user_list.rb b/lib/appwrite/models/user_list.rb index 79c4c6d3..62660196 100644 --- a/lib/appwrite/models/user_list.rb +++ b/lib/appwrite/models/user_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "users" => [] }.merge(map) UserList.new( total: map["total"], users: map["users"].map { |it| User.from(map: it) } diff --git a/lib/appwrite/models/variable.rb b/lib/appwrite/models/variable.rb index 1c14a73d..d5722127 100644 --- a/lib/appwrite/models/variable.rb +++ b/lib/appwrite/models/variable.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "key" => "", "value" => "", "secret" => false, "resourceType" => "", "resourceId" => "" }.merge(map) Variable.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/variable_list.rb b/lib/appwrite/models/variable_list.rb index 6c36b9d1..bfe9230f 100644 --- a/lib/appwrite/models/variable_list.rb +++ b/lib/appwrite/models/variable_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "variables" => [] }.merge(map) VariableList.new( total: map["total"], variables: map["variables"].map { |it| Variable.from(map: it) } diff --git a/lib/appwrite/models/vectorsdb_collection.rb b/lib/appwrite/models/vectorsdb_collection.rb index fc878665..0f3842c3 100644 --- a/lib/appwrite/models/vectorsdb_collection.rb +++ b/lib/appwrite/models/vectorsdb_collection.rb @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "databaseId" => "", "name" => "", "enabled" => true, "documentSecurity" => false, "attributes" => [], "indexes" => [], "bytesMax" => 0, "bytesUsed" => 0, "dimension" => 0 }.merge(map) VectorsdbCollection.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/vectorsdb_collection_list.rb b/lib/appwrite/models/vectorsdb_collection_list.rb index e933696b..e38a9a4d 100644 --- a/lib/appwrite/models/vectorsdb_collection_list.rb +++ b/lib/appwrite/models/vectorsdb_collection_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "collections" => [] }.merge(map) VectorsdbCollectionList.new( total: map["total"], collections: map["collections"].map { |it| VectorsdbCollection.from(map: it) } diff --git a/lib/appwrite/models/webhook.rb b/lib/appwrite/models/webhook.rb index 5e418078..333fc55b 100644 --- a/lib/appwrite/models/webhook.rb +++ b/lib/appwrite/models/webhook.rb @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "url" => "", "events" => [], "tls" => true, "authUsername" => "", "authPassword" => "", "secret" => "", "enabled" => true, "logs" => "", "attempts" => 0 }.merge(map) Webhook.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/webhook_list.rb b/lib/appwrite/models/webhook_list.rb index 1df070b9..ee1af6f5 100644 --- a/lib/appwrite/models/webhook_list.rb +++ b/lib/appwrite/models/webhook_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "webhooks" => [] }.merge(map) WebhookList.new( total: map["total"], webhooks: map["webhooks"].map { |it| Webhook.from(map: it) } diff --git a/lib/appwrite/services/account.rb b/lib/appwrite/services/account.rb index 837b7cb8..2e21f2a1 100644 --- a/lib/appwrite/services/account.rb +++ b/lib/appwrite/services/account.rb @@ -49,8 +49,6 @@ def create( password:, name: nil ) - api_path = '/account' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -63,6 +61,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account' + api_params = { userId: user_id, email: email, @@ -126,13 +126,13 @@ def list_consents( def get_consent( consent_id: ) - api_path = '/account/consents/{consentId}' - .gsub('{consentId}', consent_id) - - if consent_id.nil? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end + api_path = '/account/consents/{consentId}' + .gsub('{consentId}', consent_id) + api_params = {} api_headers = { @@ -159,13 +159,13 @@ def get_consent( def delete_consent( consent_id: ) - api_path = '/account/consents/{consentId}' - .gsub('{consentId}', consent_id) - - if consent_id.nil? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end + api_path = '/account/consents/{consentId}' + .gsub('{consentId}', consent_id) + api_params = {} api_headers = { @@ -196,13 +196,13 @@ def list_consent_tokens( queries: nil, total: nil ) - api_path = '/account/consents/{consentId}/tokens' - .gsub('{consentId}', consent_id) - - if consent_id.nil? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end + api_path = '/account/consents/{consentId}/tokens' + .gsub('{consentId}', consent_id) + api_params = { queries: queries, total: total, @@ -233,18 +233,18 @@ 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? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/account/consents/{consentId}/tokens/{tokenId}' + .gsub('{consentId}', consent_id) + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { @@ -273,18 +273,18 @@ 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? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/account/consents/{consentId}/tokens/{tokenId}' + .gsub('{consentId}', consent_id) + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { @@ -318,8 +318,6 @@ def update_email( email:, password: ) - api_path = '/account/email' - if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end @@ -328,6 +326,8 @@ def update_email( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/email' + api_params = { email: email, password: password, @@ -387,57 +387,26 @@ def list_identities( def delete_identity( identity_id: ) - api_path = '/account/identities/{identityId}' - .gsub('{identityId}', identity_id) - - if identity_id.nil? + if identity_id.nil? || identity_id == '' raise Appwrite::Exception.new('Missing required parameter: "identityId"') end + api_path = '/account/identities/{identityId}' + .gsub('{identityId}', identity_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', - } - - @client.call( - method: 'DELETE', - path: api_path, - headers: api_headers, - params: api_params, - ) - end - - # Get the list of latest security activity logs for the currently logged in - # user. Each log returns user IP address, location and date and time of log. - # - # @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). Only supported methods are limit and offset - # @param [] total When set to false, the total count returned will be 0 and will not be calculated. - # - # @return [LogList] - def list_logs( - queries: nil, - total: nil - ) - api_path = '/account/logs' - - api_params = { - queries: queries, - total: total, - } - - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( - method: 'GET', + method: 'DELETE', path: api_path, headers: api_headers, params: api_params, - response_type: Models::LogList ) end @@ -449,12 +418,12 @@ def list_logs( def update_mfa( mfa: ) - api_path = '/account/mfa' - if mfa.nil? raise Appwrite::Exception.new('Missing required parameter: "mfa"') end + api_path = '/account/mfa' + api_params = { mfa: mfa, } @@ -485,13 +454,13 @@ def update_mfa( def create_mfa_authenticator( type: ) - api_path = '/account/mfa/authenticators/{type}' - .gsub('{type}', type) - if type.nil? raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/account/mfa/authenticators/{type}' + .gsub('{type}', type) + api_params = {} api_headers = { @@ -521,9 +490,6 @@ def update_mfa_authenticator( type:, otp: ) - api_path = '/account/mfa/authenticators/{type}' - .gsub('{type}', type) - if type.nil? raise Appwrite::Exception.new('Missing required parameter: "type"') end @@ -532,6 +498,9 @@ def update_mfa_authenticator( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/account/mfa/authenticators/{type}' + .gsub('{type}', type) + api_params = { otp: otp, } @@ -559,18 +528,19 @@ def update_mfa_authenticator( def delete_mfa_authenticator( type: ) - api_path = '/account/mfa/authenticators/{type}' - .gsub('{type}', type) - if type.nil? raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/account/mfa/authenticators/{type}' + .gsub('{type}', type) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -591,12 +561,12 @@ def delete_mfa_authenticator( def create_mfa_challenge( factor: ) - api_path = '/account/mfa/challenges' - if factor.nil? raise Appwrite::Exception.new('Missing required parameter: "factor"') end + api_path = '/account/mfa/challenges' + api_params = { factor: factor, } @@ -630,8 +600,6 @@ def update_mfa_challenge( challenge_id:, otp: ) - api_path = '/account/mfa/challenges' - if challenge_id.nil? raise Appwrite::Exception.new('Missing required parameter: "challengeId"') end @@ -640,6 +608,8 @@ def update_mfa_challenge( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/account/mfa/challenges' + api_params = { challengeId: challenge_id, otp: otp, @@ -772,12 +742,12 @@ def update_mfa_recovery_codes() def update_name( name: ) - api_path = '/account/name' - if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/account/name' + api_params = { name: name, } @@ -1029,12 +999,12 @@ def update_password( password:, old_password: nil ) - api_path = '/account/password' - if password.nil? raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/password' + api_params = { password: password, oldPassword: old_password, @@ -1069,8 +1039,6 @@ def update_phone( phone:, password: ) - api_path = '/account/phone' - if phone.nil? raise Appwrite::Exception.new('Missing required parameter: "phone"') end @@ -1079,6 +1047,8 @@ def update_phone( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/phone' + api_params = { phone: phone, password: password, @@ -1132,12 +1102,12 @@ def get_prefs() def update_prefs( prefs: ) - api_path = '/account/prefs' - if prefs.nil? raise Appwrite::Exception.new('Missing required parameter: "prefs"') end + api_path = '/account/prefs' + api_params = { prefs: prefs, } @@ -1174,8 +1144,6 @@ def create_recovery( email:, url: ) - api_path = '/account/recovery' - if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end @@ -1184,6 +1152,8 @@ def create_recovery( raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/account/recovery' + api_params = { email: email, url: url, @@ -1225,8 +1195,6 @@ def update_recovery( secret:, password: ) - api_path = '/account/recovery' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1239,6 +1207,8 @@ def update_recovery( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/recovery' + api_params = { userId: user_id, secret: secret, @@ -1392,7 +1362,8 @@ def list_sessions( end # Delete all sessions from the user account and remove any sessions cookies - # from the end client. + # from the end client. Pass `current` as false to keep the session making the + # request and sign out of every other session. # # @param [] current Delete the current session too. Use false to sign out of every other session while staying signed in on this one. # @@ -1409,6 +1380,7 @@ def delete_sessions( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1451,6 +1423,9 @@ def create_anonymous_session() # Allow the user to login into their account by providing a valid email and # password combination. This route will create a new session for the user. + # Use the optional `duration` parameter to create a shorter session, for + # example when the user doesn't choose "remember me". It must be at least 60 + # seconds and cannot exceed the project maximum session length. # # A user is limited to 10 active sessions at a time by default. [Learn more # about session @@ -1466,8 +1441,6 @@ def create_email_password_session( password:, duration: nil ) - api_path = '/account/sessions/email' - if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end @@ -1476,6 +1449,8 @@ def create_email_password_session( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/sessions/email' + api_params = { email: email, password: password, @@ -1605,8 +1580,6 @@ def update_magic_url_session( user_id:, secret: ) - api_path = '/account/sessions/magic-url' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1615,6 +1588,8 @@ def update_magic_url_session( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/sessions/magic-url' + api_params = { userId: user_id, secret: secret, @@ -1650,8 +1625,6 @@ def update_phone_session( user_id:, secret: ) - api_path = '/account/sessions/phone' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1660,6 +1633,8 @@ def update_phone_session( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/sessions/phone' + api_params = { userId: user_id, secret: secret, @@ -1692,8 +1667,6 @@ def create_session( user_id:, secret: ) - api_path = '/account/sessions/token' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1702,6 +1675,8 @@ def create_session( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/sessions/token' + api_params = { userId: user_id, secret: secret, @@ -1731,13 +1706,13 @@ def create_session( def get_session( session_id: ) - api_path = '/account/sessions/{sessionId}' - .gsub('{sessionId}', session_id) - - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/account/sessions/{sessionId}' + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { @@ -1764,13 +1739,13 @@ def get_session( def update_session( session_id: ) - api_path = '/account/sessions/{sessionId}' - .gsub('{sessionId}', session_id) - - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/account/sessions/{sessionId}' + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { @@ -1800,18 +1775,19 @@ def update_session( def delete_session( session_id: ) - api_path = '/account/sessions/{sessionId}' - .gsub('{sessionId}', session_id) - - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/account/sessions/{sessionId}' + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1873,8 +1849,6 @@ def create_email_token( email:, phrase: nil ) - api_path = '/account/tokens/email' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1883,6 +1857,8 @@ def create_email_token( raise Appwrite::Exception.new('Missing required parameter: "email"') end + api_path = '/account/tokens/email' + api_params = { userId: user_id, email: email, @@ -1931,8 +1907,6 @@ def create_magic_url_token( url: nil, phrase: nil ) - api_path = '/account/tokens/magic-url' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1941,6 +1915,8 @@ def create_magic_url_token( raise Appwrite::Exception.new('Missing required parameter: "email"') end + api_path = '/account/tokens/magic-url' + api_params = { userId: user_id, email: email, @@ -1974,11 +1950,15 @@ def create_magic_url_token( # session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) # endpoint. # + # If there is already an active session, the OAuth2 identity is attached to + # the logged-in account and that session stays active until the token is + # exchanged for a new one. + # # A user is limited to 10 active sessions at a time by default. [Learn more # about session # limits](https://appwrite.io/docs/authentication-security#limits). # - # @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + # @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom. # @param [String] success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. # @param [String] failure URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. # @param [Array] scopes A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. @@ -1992,13 +1972,13 @@ def create_o_auth2_token( scopes: nil, state: nil ) - api_path = '/account/tokens/oauth2/{provider}' - .gsub('{provider}', provider) - if provider.nil? raise Appwrite::Exception.new('Missing required parameter: "provider"') end + api_path = '/account/tokens/oauth2/{provider}' + .gsub('{provider}', provider) + api_params = { success: success, failure: failure, @@ -2117,8 +2097,6 @@ def create_phone_token( user_id:, phone: ) - api_path = '/account/tokens/phone' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2127,6 +2105,8 @@ def create_phone_token( raise Appwrite::Exception.new('Missing required parameter: "phone"') end + api_path = '/account/tokens/phone' + api_params = { userId: user_id, phone: phone, @@ -2169,12 +2149,12 @@ def create_phone_token( def create_email_verification( url: ) - api_path = '/account/verifications/email' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/account/verifications/email' + api_params = { url: url, } @@ -2219,12 +2199,12 @@ def create_email_verification( def create_verification( url: ) - api_path = '/account/verifications/email' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/account/verifications/email' + api_params = { url: url, } @@ -2257,8 +2237,6 @@ def update_email_verification( user_id:, secret: ) - api_path = '/account/verifications/email' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2267,6 +2245,8 @@ def update_email_verification( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/verifications/email' + api_params = { userId: user_id, secret: secret, @@ -2303,8 +2283,6 @@ def update_verification( user_id:, secret: ) - api_path = '/account/verifications/email' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2313,6 +2291,8 @@ def update_verification( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/verifications/email' + api_params = { userId: user_id, secret: secret, @@ -2465,8 +2445,6 @@ def update_phone_verification( user_id:, secret: ) - api_path = '/account/verifications/phone' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2475,6 +2453,8 @@ def update_phone_verification( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/verifications/phone' + api_params = { userId: user_id, secret: secret, diff --git a/lib/appwrite/services/activities.rb b/lib/appwrite/services/activities.rb index 2c4c457f..e6030e18 100644 --- a/lib/appwrite/services/activities.rb +++ b/lib/appwrite/services/activities.rb @@ -43,13 +43,13 @@ def list_events( def get_event( event_id: ) - api_path = '/activities/events/{eventId}' - .gsub('{eventId}', event_id) - - if event_id.nil? + if event_id.nil? || event_id == '' raise Appwrite::Exception.new('Missing required parameter: "eventId"') end + api_path = '/activities/events/{eventId}' + .gsub('{eventId}', event_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/advisor.rb b/lib/appwrite/services/advisor.rb index 7efe9fa7..180fb950 100644 --- a/lib/appwrite/services/advisor.rb +++ b/lib/appwrite/services/advisor.rb @@ -49,13 +49,13 @@ def list_reports( def get_report( report_id: ) - api_path = '/reports/{reportId}' - .gsub('{reportId}', report_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end + api_path = '/reports/{reportId}' + .gsub('{reportId}', report_id) + api_params = {} api_headers = { @@ -82,18 +82,19 @@ def get_report( def delete_report( report_id: ) - api_path = '/reports/{reportId}' - .gsub('{reportId}', report_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end + api_path = '/reports/{reportId}' + .gsub('{reportId}', report_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -118,13 +119,13 @@ def list_insights( queries: nil, total: nil ) - api_path = '/reports/{reportId}/insights' - .gsub('{reportId}', report_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end + api_path = '/reports/{reportId}/insights' + .gsub('{reportId}', report_id) + api_params = { queries: queries, total: total, @@ -155,18 +156,18 @@ def get_insight( report_id:, insight_id: ) - api_path = '/reports/{reportId}/insights/{insightId}' - .gsub('{reportId}', report_id) - .gsub('{insightId}', insight_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end - if insight_id.nil? + if insight_id.nil? || insight_id == '' raise Appwrite::Exception.new('Missing required parameter: "insightId"') end + api_path = '/reports/{reportId}/insights/{insightId}' + .gsub('{reportId}', report_id) + .gsub('{insightId}', insight_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/apps.rb b/lib/appwrite/services/apps.rb index c4c15c1f..ceeb7dca 100644 --- a/lib/appwrite/services/apps.rb +++ b/lib/appwrite/services/apps.rb @@ -81,8 +81,6 @@ def create( device_flow: nil, team_id: nil ) - api_path = '/apps' - if app_id.nil? raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -95,6 +93,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "redirectUris"') end + api_path = '/apps' + api_params = { appId: app_id, name: name, @@ -186,13 +186,13 @@ def list_o_auth2_scopes() def get( app_id: ) - api_path = '/apps/{appId}' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -255,10 +255,7 @@ def update( installation_scopes: nil, installation_redirect_url: nil ) - api_path = '/apps/{appId}' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -266,6 +263,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/apps/{appId}' + .gsub('{appId}', app_id) + api_params = { name: name, description: description, @@ -311,13 +311,13 @@ def update( def delete( app_id: ) - api_path = '/apps/{appId}' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -348,13 +348,13 @@ def list_installations( queries: nil, total: nil ) - api_path = '/apps/{appId}/installations' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/installations' + .gsub('{appId}', app_id) + api_params = { queries: queries, total: total, @@ -386,18 +386,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/apps/{appId}/installations/{installationId}' + .gsub('{appId}', app_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -426,18 +426,18 @@ def delete_installation( app_id:, installation_id: ) - api_path = '/apps/{appId}/installations/{installationId}' - .gsub('{appId}', app_id) - .gsub('{installationId}', installation_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/apps/{appId}/installations/{installationId}' + .gsub('{appId}', app_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -471,18 +471,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/apps/{appId}/installations/{installationId}/tokens' + .gsub('{appId}', app_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -512,13 +512,13 @@ def list_keys( queries: nil, total: nil ) - api_path = '/apps/{appId}/keys' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/keys' + .gsub('{appId}', app_id) + api_params = { queries: queries, total: total, @@ -548,13 +548,13 @@ def list_keys( def create_key( app_id: ) - api_path = '/apps/{appId}/keys' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/keys' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -582,18 +582,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/apps/{appId}/keys/{keyId}' + .gsub('{appId}', app_id) + .gsub('{keyId}', key_id) + api_params = {} api_headers = { @@ -620,18 +620,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/apps/{appId}/keys/{keyId}' + .gsub('{appId}', app_id) + .gsub('{keyId}', key_id) + api_params = {} api_headers = { @@ -653,17 +653,14 @@ def delete_key( # 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. + # @param [Array] labels Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. Reserved labels are rejected. # # @return [App] def update_labels( app_id:, labels: ) - api_path = '/apps/{appId}/labels' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -671,6 +668,9 @@ def update_labels( raise Appwrite::Exception.new('Missing required parameter: "labels"') end + api_path = '/apps/{appId}/labels' + .gsub('{appId}', app_id) + api_params = { labels: labels, } @@ -702,13 +702,13 @@ def list_secrets( queries: nil, total: nil ) - api_path = '/apps/{appId}/secrets' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/secrets' + .gsub('{appId}', app_id) + api_params = { queries: queries, total: total, @@ -736,13 +736,13 @@ def list_secrets( def create_secret( app_id: ) - api_path = '/apps/{appId}/secrets' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/secrets' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -770,18 +770,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if secret_id.nil? + if secret_id.nil? || secret_id == '' raise Appwrite::Exception.new('Missing required parameter: "secretId"') end + api_path = '/apps/{appId}/secrets/{secretId}' + .gsub('{appId}', app_id) + .gsub('{secretId}', secret_id) + api_params = {} api_headers = { @@ -808,18 +808,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if secret_id.nil? + if secret_id.nil? || secret_id == '' raise Appwrite::Exception.new('Missing required parameter: "secretId"') end + api_path = '/apps/{appId}/secrets/{secretId}' + .gsub('{appId}', app_id) + .gsub('{secretId}', secret_id) + api_params = {} api_headers = { @@ -846,10 +846,7 @@ def update_team( app_id:, team_id: ) - api_path = '/apps/{appId}/team' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -857,6 +854,9 @@ def update_team( raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/apps/{appId}/team' + .gsub('{appId}', app_id) + api_params = { teamId: team_id, } @@ -884,13 +884,13 @@ def update_team( def delete_tokens( app_id: ) - api_path = '/apps/{appId}/tokens' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/tokens' + .gsub('{appId}', app_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/avatars.rb b/lib/appwrite/services/avatars.rb index d3ab6a03..1555c4f2 100644 --- a/lib/appwrite/services/avatars.rb +++ b/lib/appwrite/services/avatars.rb @@ -29,13 +29,13 @@ def get_browser( height: nil, quality: nil ) - api_path = '/avatars/browsers/{code}' - .gsub('{code}', code) - if code.nil? raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/avatars/browsers/{code}' + .gsub('{code}', code) + api_params = { width: width, height: height, @@ -77,13 +77,13 @@ def get_credit_card( height: nil, quality: nil ) - api_path = '/avatars/credit-cards/{code}' - .gsub('{code}', code) - if code.nil? raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/avatars/credit-cards/{code}' + .gsub('{code}', code) + api_params = { width: width, height: height, @@ -114,12 +114,12 @@ def get_credit_card( def get_favicon( url: ) - api_path = '/avatars/favicon' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/avatars/favicon' + api_params = { url: url, } @@ -160,13 +160,13 @@ def get_flag( height: nil, quality: nil ) - api_path = '/avatars/flags/{code}' - .gsub('{code}', code) - if code.nil? raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/avatars/flags/{code}' + .gsub('{code}', code) + api_params = { width: width, height: height, @@ -208,12 +208,12 @@ def get_image( width: nil, height: nil ) - api_path = '/avatars/image' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/avatars/image' + api_params = { url: url, width: width, @@ -285,9 +285,9 @@ def get_initials( end # Returns the best available profile photo for a user. The endpoint tries - # each source in priority order and returns the first successful result: - # OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in - # static fallback. + # each source in priority order and returns the first successful result: a + # custom uploaded photo (see avatars.updatePhoto), OAuth2 identity photo, + # Gravatar, Libravatar, Appwrite Initials, built-in static fallback. # # Passing `userId` — `current()` for the authenticated user — resolves # the photo from everything known about that user: identity photos, email, @@ -433,12 +433,12 @@ def get_qr( margin: nil, download: nil ) - api_path = '/avatars/qr' - if text.nil? raise Appwrite::Exception.new('Missing required parameter: "text"') end + api_path = '/avatars/qr' + api_params = { text: text, size: size, @@ -471,7 +471,7 @@ def get_qr( # dimensions are not specified, the default viewport size is 1280x720px. # # @param [String] url Website URL which you want to capture. - # @param [Hash] headers HTTP headers to send with the browser request. Defaults to empty. + # @param [Hash] headers HTTP headers to send with the browser request. Only Accept and Accept-Language are allowed. Defaults to empty. # @param [Integer] viewport_width Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. # @param [Integer] viewport_height Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720. # @param [Float] scale Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1. @@ -514,12 +514,12 @@ def get_screenshot( quality: nil, output: nil ) - api_path = '/avatars/screenshots' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/avatars/screenshots' + api_params = { url: url, headers: headers, diff --git a/lib/appwrite/services/backups.rb b/lib/appwrite/services/backups.rb index f74a5917..9d58c7bf 100644 --- a/lib/appwrite/services/backups.rb +++ b/lib/appwrite/services/backups.rb @@ -44,12 +44,12 @@ def create_archive( services:, resource_id: nil ) - api_path = '/backups/archives' - if services.nil? raise Appwrite::Exception.new('Missing required parameter: "services"') end + api_path = '/backups/archives' + api_params = { services: services, resourceId: resource_id, @@ -78,13 +78,13 @@ def create_archive( def get_archive( archive_id: ) - api_path = '/backups/archives/{archiveId}' - .gsub('{archiveId}', archive_id) - - if archive_id.nil? + if archive_id.nil? || archive_id == '' raise Appwrite::Exception.new('Missing required parameter: "archiveId"') end + api_path = '/backups/archives/{archiveId}' + .gsub('{archiveId}', archive_id) + api_params = {} api_headers = { @@ -109,13 +109,13 @@ def get_archive( def delete_archive( archive_id: ) - api_path = '/backups/archives/{archiveId}' - .gsub('{archiveId}', archive_id) - - if archive_id.nil? + if archive_id.nil? || archive_id == '' raise Appwrite::Exception.new('Missing required parameter: "archiveId"') end + api_path = '/backups/archives/{archiveId}' + .gsub('{archiveId}', archive_id) + api_params = {} api_headers = { @@ -180,8 +180,6 @@ def create_policy( resource_id: nil, enabled: nil ) - api_path = '/backups/policies' - if policy_id.nil? raise Appwrite::Exception.new('Missing required parameter: "policyId"') end @@ -198,6 +196,8 @@ def create_policy( raise Appwrite::Exception.new('Missing required parameter: "schedule"') end + api_path = '/backups/policies' + api_params = { policyId: policy_id, name: name, @@ -231,13 +231,13 @@ def create_policy( def get_policy( policy_id: ) - api_path = '/backups/policies/{policyId}' - .gsub('{policyId}', policy_id) - - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/backups/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -270,13 +270,13 @@ def update_policy( schedule: nil, enabled: nil ) - api_path = '/backups/policies/{policyId}' - .gsub('{policyId}', policy_id) - - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/backups/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = { name: name, retention: retention, @@ -307,13 +307,13 @@ def update_policy( def delete_policy( policy_id: ) - api_path = '/backups/policies/{policyId}' - .gsub('{policyId}', policy_id) - - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/backups/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -375,8 +375,6 @@ def create_restoration( new_resource_id: nil, new_resource_name: nil ) - api_path = '/backups/restoration' - if archive_id.nil? raise Appwrite::Exception.new('Missing required parameter: "archiveId"') end @@ -385,6 +383,8 @@ def create_restoration( raise Appwrite::Exception.new('Missing required parameter: "services"') end + api_path = '/backups/restoration' + api_params = { archiveId: archive_id, services: services, @@ -443,13 +443,13 @@ def list_restorations( def get_restoration( restoration_id: ) - api_path = '/backups/restorations/{restorationId}' - .gsub('{restorationId}', restoration_id) - - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/backups/restorations/{restorationId}' + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/databases.rb b/lib/appwrite/services/databases.rb index c8783184..46bb76c1 100644 --- a/lib/appwrite/services/databases.rb +++ b/lib/appwrite/services/databases.rb @@ -60,8 +60,6 @@ def create( name:, enabled: nil ) - api_path = '/databases' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -70,6 +68,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/databases' + api_params = { databaseId: database_id, name: name, @@ -168,13 +168,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/databases/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -206,13 +206,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/databases/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -244,18 +244,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/databases/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -279,13 +280,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/databases/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -317,13 +318,13 @@ def create_operations( def get( database_id: ) - api_path = '/databases/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -355,13 +356,13 @@ def update( name: nil, enabled: nil ) - api_path = '/databases/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -394,18 +395,19 @@ def update( def delete( database_id: ) - api_path = '/databases/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -434,13 +436,13 @@ def list_collections( search: nil, total: nil ) - api_path = '/databases/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -476,7 +478,7 @@ def list_collections( # @param [] document_security Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] enabled Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. # @param [Array] attributes Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. - # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). # # @return [Collection] def create_collection( @@ -489,10 +491,7 @@ def create_collection( attributes: nil, indexes: nil ) - api_path = '/databases/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -504,6 +503,9 @@ def create_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/databases/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { collectionId: collection_id, name: name, @@ -543,18 +545,18 @@ def get_collection( database_id:, collection_id: ) - api_path = '/databases/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { @@ -594,18 +596,18 @@ def update_collection( enabled: nil, purge: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { name: name, permissions: permissions, @@ -643,23 +645,24 @@ def delete_collection( database_id:, collection_id: ) - api_path = '/databases/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -687,18 +690,18 @@ def list_attributes( queries: nil, total: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -745,15 +748,11 @@ def create_big_int_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -765,6 +764,10 @@ def create_big_int_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -816,20 +819,15 @@ def update_big_int_attribute( max: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -841,6 +839,11 @@ def update_big_int_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -886,15 +889,11 @@ def create_boolean_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -906,6 +905,10 @@ def create_boolean_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -950,20 +953,15 @@ def update_boolean_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -975,6 +973,11 @@ def update_boolean_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1017,15 +1020,11 @@ def create_datetime_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1037,6 +1036,10 @@ def create_datetime_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1081,20 +1084,15 @@ def update_datetime_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1106,6 +1104,11 @@ def update_datetime_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1149,15 +1152,11 @@ def create_email_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1169,6 +1168,10 @@ def create_email_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1214,20 +1217,15 @@ def update_email_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1239,6 +1237,11 @@ def update_email_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1285,15 +1288,11 @@ def create_enum_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1309,6 +1308,10 @@ def create_enum_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, elements: elements, @@ -1357,20 +1360,15 @@ def update_enum_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1386,6 +1384,11 @@ def update_enum_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { elements: elements, required: required, @@ -1435,15 +1438,11 @@ def create_float_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1455,6 +1454,10 @@ def create_float_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1506,20 +1509,15 @@ def update_float_attribute( max: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1531,6 +1529,11 @@ def update_float_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1581,15 +1584,11 @@ def create_integer_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1601,6 +1600,10 @@ def create_integer_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1652,20 +1655,15 @@ def update_integer_attribute( max: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1677,6 +1675,11 @@ def update_integer_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1722,15 +1725,11 @@ def create_ip_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1742,6 +1741,10 @@ def create_ip_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1787,20 +1790,15 @@ def update_ip_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1812,6 +1810,11 @@ def update_ip_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1852,15 +1855,11 @@ def create_line_attribute( required:, default: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1872,6 +1871,10 @@ def create_line_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1915,20 +1918,15 @@ def update_line_attribute( default: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1936,6 +1934,11 @@ def update_line_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1981,15 +1984,11 @@ def create_longtext_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2001,6 +2000,10 @@ def create_longtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2047,20 +2050,15 @@ def update_longtext_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2072,6 +2070,11 @@ def update_longtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2117,15 +2120,11 @@ def create_mediumtext_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2137,6 +2136,10 @@ def create_mediumtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2183,20 +2186,15 @@ def update_mediumtext_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2208,6 +2206,11 @@ def update_mediumtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2248,15 +2251,11 @@ def create_point_attribute( required:, default: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2268,6 +2267,10 @@ def create_point_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2311,20 +2314,15 @@ def update_point_attribute( default: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2332,6 +2330,11 @@ def update_point_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2372,15 +2375,11 @@ def create_polygon_attribute( required:, default: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2392,6 +2391,10 @@ def create_polygon_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2435,20 +2438,15 @@ def update_polygon_attribute( default: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2456,6 +2454,11 @@ def update_polygon_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2504,15 +2507,11 @@ def create_relationship_attribute( two_way_key: nil, on_delete: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2524,6 +2523,10 @@ def create_relationship_attribute( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { relatedCollectionId: related_collection_id, type: type, @@ -2569,23 +2572,23 @@ def update_relationship_attribute( on_delete: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { onDelete: on_delete, newKey: new_key, @@ -2632,15 +2635,11 @@ def create_string_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2656,6 +2655,10 @@ def create_string_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, size: size, @@ -2705,20 +2708,15 @@ def update_string_attribute( size: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2730,6 +2728,11 @@ def update_string_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2776,15 +2779,11 @@ def create_text_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2796,6 +2795,10 @@ def create_text_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2842,20 +2845,15 @@ def update_text_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2867,6 +2865,11 @@ def update_text_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2910,15 +2913,11 @@ def create_url_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2930,6 +2929,10 @@ def create_url_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2975,20 +2978,15 @@ def update_url_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3000,6 +2998,11 @@ def update_url_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3047,15 +3050,11 @@ def create_varchar_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3071,6 +3070,10 @@ def create_varchar_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, size: size, @@ -3120,20 +3123,15 @@ def update_varchar_attribute( size: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3145,6 +3143,11 @@ def update_varchar_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3176,29 +3179,29 @@ def update_varchar_attribute( # @param [String] collection_id Collection ID. # @param [String] key Attribute Key. # - # @return [AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributeString] + # @return [AttributeBoolean, AttributeBigint, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributePoint, AttributeLine, AttributePolygon, AttributeVarchar, AttributeText, AttributeMediumtext, AttributeLongtext, AttributeString] def get_attribute( database_id:, collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -3242,6 +3245,11 @@ def get_attribute( return Models::AttributeBoolean.from(map: response) end + if response['type'] == 'bigint' + + return Models::AttributeBigint.from(map: response) + end + if response['type'] == 'integer' return Models::AttributeInteger.from(map: response) @@ -3262,6 +3270,41 @@ def get_attribute( return Models::AttributeRelationship.from(map: response) end + if response['type'] == 'point' + + return Models::AttributePoint.from(map: response) + end + + if response['type'] == 'linestring' + + return Models::AttributeLine.from(map: response) + end + + if response['type'] == 'polygon' + + return Models::AttributePolygon.from(map: response) + end + + if response['type'] == 'varchar' + + return Models::AttributeVarchar.from(map: response) + end + + if response['type'] == 'text' + + return Models::AttributeText.from(map: response) + end + + if response['type'] == 'mediumtext' + + return Models::AttributeMediumtext.from(map: response) + end + + if response['type'] == 'longtext' + + return Models::AttributeLongtext.from(map: response) + end + if response['type'] == 'string' return Models::AttributeString.from(map: response) @@ -3285,28 +3328,29 @@ def delete_attribute( collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3339,18 +3383,18 @@ def list_documents( total: nil, ttl: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3396,15 +3440,11 @@ def create_document( permissions: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3416,6 +3456,10 @@ def create_document( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documentId: document_id, data: data, @@ -3458,15 +3502,11 @@ def create_documents( documents:, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3474,6 +3514,10 @@ def create_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -3515,15 +3559,11 @@ def upsert_documents( documents:, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3531,6 +3571,10 @@ def upsert_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -3572,18 +3616,18 @@ def update_documents( queries: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { data: data, queries: queries, @@ -3623,18 +3667,18 @@ def delete_documents( queries: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3675,23 +3719,23 @@ def get_document( queries: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3735,23 +3779,23 @@ def upsert_document( permissions: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -3795,23 +3839,23 @@ def update_document( permissions: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -3850,23 +3894,23 @@ def delete_document( document_id:, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { transactionId: transaction_id, } @@ -3874,6 +3918,7 @@ def delete_document( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3907,28 +3952,28 @@ def decrement_document_attribute( min: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, min: min, @@ -3973,28 +4018,28 @@ def increment_document_attribute( max: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, max: max, @@ -4033,18 +4078,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -4069,7 +4114,9 @@ def list_indexes( # # Creates an index on the attributes listed. Your index should include all # the attributes you will query in a single request. - # Attributes can be `key`, `fulltext`, and `unique`. + # Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. + # `trigram` is only available on PostgreSQL and lets `contains`, + # `startsWith`, and `endsWith` queries on string attributes use an index. # # @param [String] database_id Database ID. # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4089,15 +4136,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -4113,6 +4156,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "attributes"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, type: type, @@ -4151,23 +4198,23 @@ def get_index( collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -4199,28 +4246,29 @@ def delete_index( collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/documents_db.rb b/lib/appwrite/services/documents_db.rb index f97888a7..efa8021e 100644 --- a/lib/appwrite/services/documents_db.rb +++ b/lib/appwrite/services/documents_db.rb @@ -57,8 +57,6 @@ def create( replicas: nil, sync_mode: nil ) - api_path = '/documentsdb' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -67,6 +65,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb' + api_params = { databaseId: database_id, name: name, @@ -92,8 +92,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -184,13 +184,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/documentsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/documentsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -254,18 +254,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/documentsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -286,13 +287,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/documentsdb/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -321,13 +322,13 @@ def create_operations( def get( database_id: ) - api_path = '/documentsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -362,10 +363,7 @@ def update( replicas: nil, sync_mode: nil ) - api_path = '/documentsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -373,6 +371,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -405,18 +406,19 @@ def update( def delete( database_id: ) - api_path = '/documentsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -442,13 +444,13 @@ def list_collections( search: nil, total: nil ) - api_path = '/documentsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -494,10 +496,7 @@ def create_collection( attributes: nil, indexes: nil ) - api_path = '/documentsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -509,6 +508,9 @@ def create_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { collectionId: collection_id, name: name, @@ -545,18 +547,18 @@ def get_collection( database_id:, collection_id: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { @@ -593,15 +595,11 @@ def update_collection( enabled: nil, purge: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -609,6 +607,10 @@ def update_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { name: name, permissions: permissions, @@ -643,23 +645,24 @@ def delete_collection( database_id:, collection_id: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -689,18 +692,18 @@ def list_documents( total: nil, ttl: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -743,15 +746,11 @@ def create_document( permissions: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -763,6 +762,10 @@ def create_document( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documentId: document_id, data: data, @@ -802,15 +805,11 @@ def create_documents( documents:, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -818,6 +817,10 @@ def create_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -856,15 +859,11 @@ def upsert_documents( documents:, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -872,6 +871,10 @@ def upsert_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -910,18 +913,18 @@ def update_documents( queries: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { data: data, queries: queries, @@ -958,18 +961,18 @@ def delete_documents( queries: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1007,23 +1010,23 @@ def get_document( queries: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1064,23 +1067,23 @@ def upsert_document( permissions: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1121,23 +1124,23 @@ def update_document( permissions: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1173,23 +1176,23 @@ def delete_document( document_id:, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { transactionId: transaction_id, } @@ -1197,6 +1200,7 @@ def delete_document( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1227,28 +1231,28 @@ def decrement_document_attribute( min: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, min: min, @@ -1290,28 +1294,28 @@ def increment_document_attribute( max: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, max: max, @@ -1347,18 +1351,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -1400,15 +1404,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1424,6 +1424,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "attributes"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, type: type, @@ -1459,23 +1463,23 @@ def get_index( collection_id:, key: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -1504,28 +1508,29 @@ def delete_index( collection_id:, key: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1554,13 +1559,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/documentsdb/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1597,13 +1602,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/documentsdb/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1633,13 +1638,13 @@ def list_operations( def get_replicas( database_id: ) - api_path = '/documentsdb/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1666,13 +1671,13 @@ def get_replicas( def get_status( database_id: ) - api_path = '/documentsdb/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/domains.rb b/lib/appwrite/services/domains.rb index 3493e9e4..42937c7d 100644 --- a/lib/appwrite/services/domains.rb +++ b/lib/appwrite/services/domains.rb @@ -174,7 +174,7 @@ def list_prices( def get( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -208,7 +208,7 @@ def get( def delete( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -243,7 +243,7 @@ def update_nameservers( domain_id:, nameservers: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -281,7 +281,7 @@ def update_nameservers( def verify_nameservers( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -313,7 +313,7 @@ def verify_nameservers( def get_preset_google_workspace( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -346,7 +346,7 @@ def get_preset_google_workspace( def create_preset_google_workspace( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -378,7 +378,7 @@ def create_preset_google_workspace( def get_preset_i_cloud( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -411,7 +411,7 @@ def get_preset_i_cloud( def create_preset_i_cloud( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -443,7 +443,7 @@ def create_preset_i_cloud( def get_preset_mailgun( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -476,7 +476,7 @@ def get_preset_mailgun( def create_preset_mailgun( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -508,7 +508,7 @@ def create_preset_mailgun( def get_preset_outlook( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -541,7 +541,7 @@ def get_preset_outlook( def create_preset_outlook( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -573,7 +573,7 @@ def create_preset_outlook( def get_preset_proton_mail( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -606,7 +606,7 @@ def get_preset_proton_mail( def create_preset_proton_mail( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -638,7 +638,7 @@ def create_preset_proton_mail( def get_preset_zoho( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -671,7 +671,7 @@ def get_preset_zoho( def create_preset_zoho( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -707,7 +707,7 @@ def list_records( domain_id:, queries: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -750,7 +750,7 @@ def create_record_a( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -813,11 +813,11 @@ def update_record_a( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -878,7 +878,7 @@ def create_record_aaaa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -941,11 +941,11 @@ def update_record_aaaa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1007,7 +1007,7 @@ def create_record_alias( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1073,11 +1073,11 @@ def update_record_alias( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1138,7 +1138,7 @@ def create_record_caa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1201,11 +1201,11 @@ def update_record_caa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1269,7 +1269,7 @@ def create_record_cname( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1328,11 +1328,11 @@ def update_record_cname( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1392,7 +1392,7 @@ def create_record_https( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1455,11 +1455,11 @@ def update_record_https( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1525,7 +1525,7 @@ def create_record_mx( priority:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1591,11 +1591,11 @@ def update_record_mx( priority:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1661,7 +1661,7 @@ def create_record_ns( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1726,11 +1726,11 @@ def update_record_ns( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1798,7 +1798,7 @@ def create_record_srv( port:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1891,11 +1891,11 @@ def update_record_srv( port:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1970,7 +1970,7 @@ def create_record_txt( value: nil, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2030,11 +2030,11 @@ def update_record_txt( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -2092,11 +2092,11 @@ def get_record( domain_id:, record_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -2132,11 +2132,11 @@ def delete_record( domain_id:, record_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -2176,7 +2176,7 @@ def update_team( domain_id:, team_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2215,7 +2215,7 @@ def update_team( def get_transfer_status( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2249,7 +2249,7 @@ def get_transfer_status( def get_zone( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2285,7 +2285,7 @@ def update_zone( domain_id:, content: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end diff --git a/lib/appwrite/services/embeddings.rb b/lib/appwrite/services/embeddings.rb index 3b7003db..e4fb2813 100644 --- a/lib/appwrite/services/embeddings.rb +++ b/lib/appwrite/services/embeddings.rb @@ -19,12 +19,12 @@ def create_text_embeddings( texts:, model: nil ) - api_path = '/embeddings/text' - if texts.nil? raise Appwrite::Exception.new('Missing required parameter: "texts"') end + api_path = '/embeddings/text' + api_params = { texts: texts, model: model, diff --git a/lib/appwrite/services/functions.rb b/lib/appwrite/services/functions.rb index dcf47e0c..d8dff4c0 100644 --- a/lib/appwrite/services/functions.rb +++ b/lib/appwrite/services/functions.rb @@ -96,8 +96,6 @@ def create( deployment_retention: nil, interval: nil ) - api_path = '/functions' - if function_id.nil? raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -110,6 +108,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "runtime"') end + api_path = '/functions' + api_params = { functionId: function_id, name: name, @@ -218,13 +218,13 @@ def list_specifications( def get( function_id: ) - api_path = '/functions/{functionId}' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}' + .gsub('{functionId}', function_id) + api_params = {} api_headers = { @@ -293,10 +293,7 @@ def update( deployment_retention: nil, interval: nil ) - api_path = '/functions/{functionId}' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -304,6 +301,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/functions/{functionId}' + .gsub('{functionId}', function_id) + api_params = { name: name, runtime: runtime, @@ -352,18 +352,19 @@ def update( def delete( function_id: ) - api_path = '/functions/{functionId}' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}' + .gsub('{functionId}', function_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -385,10 +386,7 @@ def update_function_deployment( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployment' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -396,6 +394,9 @@ def update_function_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployment' + .gsub('{functionId}', function_id) + api_params = { deploymentId: deployment_id, } @@ -430,13 +431,13 @@ def list_deployments( search: nil, total: nil ) - api_path = '/functions/{functionId}/deployments' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/deployments' + .gsub('{functionId}', function_id) + api_params = { queries: queries, search: search, @@ -483,10 +484,7 @@ def create_deployment( commands: nil, on_progress: nil ) - api_path = '/functions/{functionId}/deployments' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -498,6 +496,9 @@ def create_deployment( raise Appwrite::Exception.new('Missing required parameter: "activate"') end + api_path = '/functions/{functionId}/deployments' + .gsub('{functionId}', function_id) + api_params = { entrypoint: entrypoint, commands: commands, @@ -521,6 +522,7 @@ def create_deployment( param_name: param_name, id_param_name: id_param_name, on_progress: on_progress, + method: 'POST', response_type: Models::Deployment ) end @@ -541,10 +543,7 @@ def create_duplicate_deployment( deployment_id:, build_id: nil ) - api_path = '/functions/{functionId}/deployments/duplicate' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -552,6 +551,9 @@ def create_duplicate_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/duplicate' + .gsub('{functionId}', function_id) + api_params = { deploymentId: deployment_id, buildId: build_id, @@ -596,10 +598,7 @@ def create_template_deployment( reference:, activate: nil ) - api_path = '/functions/{functionId}/deployments/template' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -623,6 +622,9 @@ def create_template_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/functions/{functionId}/deployments/template' + .gsub('{functionId}', function_id) + api_params = { repository: repository, owner: owner, @@ -663,10 +665,7 @@ def create_vcs_deployment( reference:, activate: nil ) - api_path = '/functions/{functionId}/deployments/vcs' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -678,6 +677,9 @@ def create_vcs_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/functions/{functionId}/deployments/vcs' + .gsub('{functionId}', function_id) + api_params = { type: type, reference: reference, @@ -709,18 +711,18 @@ def get_deployment( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployments/{deploymentId}' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -747,23 +749,24 @@ def delete_deployment( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployments/{deploymentId}' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -790,18 +793,18 @@ def get_deployment_download( type: nil, token: nil ) - api_path = '/functions/{functionId}/deployments/{deploymentId}/download' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}/download' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = { type: type, token: token, @@ -834,18 +837,18 @@ def update_deployment_status( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployments/{deploymentId}/status' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}/status' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -876,13 +879,13 @@ def list_executions( queries: nil, total: nil ) - api_path = '/functions/{functionId}/executions' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/executions' + .gsub('{functionId}', function_id) + api_params = { queries: queries, total: total, @@ -925,13 +928,13 @@ def create_execution( headers: nil, scheduled_at: nil ) - api_path = '/functions/{functionId}/executions' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/executions' + .gsub('{functionId}', function_id) + api_params = { body: body, async: async, @@ -966,18 +969,18 @@ def get_execution( function_id:, execution_id: ) - api_path = '/functions/{functionId}/executions/{executionId}' - .gsub('{functionId}', function_id) - .gsub('{executionId}', execution_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if execution_id.nil? + if execution_id.nil? || execution_id == '' raise Appwrite::Exception.new('Missing required parameter: "executionId"') end + api_path = '/functions/{functionId}/executions/{executionId}' + .gsub('{functionId}', function_id) + .gsub('{executionId}', execution_id) + api_params = {} api_headers = { @@ -1004,23 +1007,24 @@ def delete_execution( function_id:, execution_id: ) - api_path = '/functions/{functionId}/executions/{executionId}' - .gsub('{functionId}', function_id) - .gsub('{executionId}', execution_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if execution_id.nil? + if execution_id.nil? || execution_id == '' raise Appwrite::Exception.new('Missing required parameter: "executionId"') end + api_path = '/functions/{functionId}/executions/{executionId}' + .gsub('{functionId}', function_id) + .gsub('{executionId}', execution_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1043,13 +1047,13 @@ def list_variables( queries: nil, total: nil ) - api_path = '/functions/{functionId}/variables' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/variables' + .gsub('{functionId}', function_id) + api_params = { queries: queries, total: total, @@ -1086,10 +1090,7 @@ def create_variable( value:, secret: nil ) - api_path = '/functions/{functionId}/variables' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -1105,6 +1106,9 @@ def create_variable( raise Appwrite::Exception.new('Missing required parameter: "value"') end + api_path = '/functions/{functionId}/variables' + .gsub('{functionId}', function_id) + api_params = { variableId: variable_id, key: key, @@ -1137,18 +1141,18 @@ def get_variable( function_id:, variable_id: ) - api_path = '/functions/{functionId}/variables/{variableId}' - .gsub('{functionId}', function_id) - .gsub('{variableId}', variable_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/functions/{functionId}/variables/{variableId}' + .gsub('{functionId}', function_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { @@ -1181,18 +1185,18 @@ def update_variable( value: nil, secret: nil ) - api_path = '/functions/{functionId}/variables/{variableId}' - .gsub('{functionId}', function_id) - .gsub('{variableId}', variable_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/functions/{functionId}/variables/{variableId}' + .gsub('{functionId}', function_id) + .gsub('{variableId}', variable_id) + api_params = { key: key, value: value, @@ -1224,23 +1228,24 @@ def delete_variable( function_id:, variable_id: ) - api_path = '/functions/{functionId}/variables/{variableId}' - .gsub('{functionId}', function_id) - .gsub('{variableId}', variable_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/functions/{functionId}/variables/{variableId}' + .gsub('{functionId}', function_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/graphql.rb b/lib/appwrite/services/graphql.rb index 210f528a..7a13b000 100644 --- a/lib/appwrite/services/graphql.rb +++ b/lib/appwrite/services/graphql.rb @@ -14,12 +14,12 @@ def initialize(client) def query( query: ) - api_path = '/graphql' - if query.nil? raise Appwrite::Exception.new('Missing required parameter: "query"') end + api_path = '/graphql' + api_params = { query: query, } @@ -47,12 +47,12 @@ def query( def mutation( query: ) - api_path = '/graphql/mutation' - if query.nil? raise Appwrite::Exception.new('Missing required parameter: "query"') end + api_path = '/graphql/mutation' + api_params = { query: query, } diff --git a/lib/appwrite/services/messaging.rb b/lib/appwrite/services/messaging.rb index ab97d81c..e37e067d 100644 --- a/lib/appwrite/services/messaging.rb +++ b/lib/appwrite/services/messaging.rb @@ -8,7 +8,7 @@ def initialize(client) # Get a list of all messages from the current Appwrite project. # - # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType + # @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: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType, users, targets # @param [String] search Search term to filter your list results. Max length: 256 chars. # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # @@ -74,8 +74,6 @@ def create_email( reply_to_email: nil, reply_to_name: nil ) - api_path = '/messaging/messages/email' - if message_id.nil? raise Appwrite::Exception.new('Missing required parameter: "messageId"') end @@ -88,6 +86,8 @@ def create_email( raise Appwrite::Exception.new('Missing required parameter: "content"') end + api_path = '/messaging/messages/email' + api_params = { messageId: message_id, subject: subject, @@ -157,13 +157,13 @@ def update_email( reply_to_email: nil, reply_to_name: nil ) - api_path = '/messaging/messages/email/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/email/{messageId}' + .gsub('{messageId}', message_id) + api_params = { topics: topics, users: users, @@ -241,12 +241,12 @@ def create_push( priority: nil, channel_id: nil ) - api_path = '/messaging/messages/push' - if message_id.nil? raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/push' + api_params = { messageId: message_id, title: title, @@ -334,13 +334,13 @@ def update_push( priority: nil, channel_id: nil ) - api_path = '/messaging/messages/push/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/push/{messageId}' + .gsub('{messageId}', message_id) + api_params = { topics: topics, users: users, @@ -398,8 +398,6 @@ def create_sms( draft: nil, scheduled_at: nil ) - api_path = '/messaging/messages/sms' - if message_id.nil? raise Appwrite::Exception.new('Missing required parameter: "messageId"') end @@ -408,6 +406,8 @@ def create_sms( raise Appwrite::Exception.new('Missing required parameter: "content"') end + api_path = '/messaging/messages/sms' + api_params = { messageId: message_id, content: content, @@ -456,13 +456,13 @@ def update_sms( draft: nil, scheduled_at: nil ) - api_path = '/messaging/messages/sms/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/sms/{messageId}' + .gsub('{messageId}', message_id) + api_params = { topics: topics, users: users, @@ -496,13 +496,13 @@ def update_sms( def get_message( message_id: ) - api_path = '/messaging/messages/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/{messageId}' + .gsub('{messageId}', message_id) + api_params = {} api_headers = { @@ -528,18 +528,19 @@ def get_message( def delete( message_id: ) - api_path = '/messaging/messages/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/{messageId}' + .gsub('{messageId}', message_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -562,13 +563,13 @@ def list_targets( queries: nil, total: nil ) - api_path = '/messaging/messages/{messageId}/targets' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/{messageId}/targets' + .gsub('{messageId}', message_id) + api_params = { queries: queries, total: total, @@ -644,8 +645,6 @@ def create_apns_provider( sandbox: nil, enabled: nil ) - api_path = '/messaging/providers/apns' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -654,6 +653,8 @@ def create_apns_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/apns' + api_params = { providerId: provider_id, name: name, @@ -702,13 +703,13 @@ def update_apns_provider( bundle_id: nil, sandbox: nil ) - api_path = '/messaging/providers/apns/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/apns/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -740,7 +741,7 @@ def update_apns_provider( # @param [String] name Provider name. # @param [] enabled Set as enabled. # @param [Integer] qos Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. # # @return [Provider] def create_appwrite_provider( @@ -789,7 +790,7 @@ def create_appwrite_provider( # @param [String] name Provider name. # @param [] enabled Set as enabled. # @param [Integer] qos Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. # # @return [Provider] def update_appwrite_provider( @@ -799,7 +800,7 @@ def update_appwrite_provider( qos: nil, expiry: nil ) - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -842,8 +843,6 @@ def create_fcm_provider( service_account_json: nil, enabled: nil ) - api_path = '/messaging/providers/fcm' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -852,6 +851,8 @@ def create_fcm_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/fcm' + api_params = { providerId: provider_id, name: name, @@ -888,13 +889,13 @@ def update_fcm_provider( enabled: nil, service_account_json: nil ) - api_path = '/messaging/providers/fcm/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/fcm/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -942,8 +943,6 @@ def create_mailgun_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/mailgun' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -952,6 +951,8 @@ def create_mailgun_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/mailgun' + api_params = { providerId: provider_id, name: name, @@ -1006,13 +1007,13 @@ def update_mailgun_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/mailgun/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/mailgun/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, apiKey: api_key, @@ -1058,8 +1059,6 @@ def create_msg91_provider( auth_key: nil, enabled: nil ) - api_path = '/messaging/providers/msg91' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1068,6 +1067,8 @@ def create_msg91_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/msg91' + api_params = { providerId: provider_id, name: name, @@ -1110,13 +1111,13 @@ def update_msg91_provider( sender_id: nil, auth_key: nil ) - api_path = '/messaging/providers/msg91/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/msg91/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1162,8 +1163,6 @@ def create_resend_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/resend' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1172,6 +1171,8 @@ def create_resend_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/resend' + api_params = { providerId: provider_id, name: name, @@ -1220,13 +1221,13 @@ def update_resend_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/resend/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/resend/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1274,8 +1275,6 @@ def create_sendgrid_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/sendgrid' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1284,6 +1283,8 @@ def create_sendgrid_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/sendgrid' + api_params = { providerId: provider_id, name: name, @@ -1332,13 +1333,13 @@ def update_sendgrid_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/sendgrid/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/sendgrid/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1390,8 +1391,6 @@ def create_ses_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/ses' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1400,6 +1399,8 @@ def create_ses_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/ses' + api_params = { providerId: provider_id, name: name, @@ -1454,13 +1455,13 @@ def update_ses_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/ses/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/ses/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1522,8 +1523,6 @@ def create_smtp_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/smtp' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1536,6 +1535,8 @@ def create_smtp_provider( raise Appwrite::Exception.new('Missing required parameter: "host"') end + api_path = '/messaging/providers/smtp' + api_params = { providerId: provider_id, name: name, @@ -1602,13 +1603,13 @@ def update_smtp_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/smtp/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/smtp/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, host: host, @@ -1658,8 +1659,6 @@ def create_telesign_provider( api_key: nil, enabled: nil ) - api_path = '/messaging/providers/telesign' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1668,6 +1667,8 @@ def create_telesign_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/telesign' + api_params = { providerId: provider_id, name: name, @@ -1710,13 +1711,13 @@ def update_telesign_provider( api_key: nil, from: nil ) - api_path = '/messaging/providers/telesign/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/telesign/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1758,8 +1759,6 @@ def create_textmagic_provider( api_key: nil, enabled: nil ) - api_path = '/messaging/providers/textmagic' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1768,6 +1767,8 @@ def create_textmagic_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/textmagic' + api_params = { providerId: provider_id, name: name, @@ -1810,13 +1811,13 @@ def update_textmagic_provider( api_key: nil, from: nil ) - api_path = '/messaging/providers/textmagic/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/textmagic/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1844,7 +1845,7 @@ def update_textmagic_provider( # # @param [String] provider_id Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. # @param [String] name Provider name. - # @param [String] from Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + # @param [String] from Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. # @param [String] account_sid Twilio account secret ID. # @param [String] auth_token Twilio authentication token. # @param [] enabled Set as enabled. @@ -1858,8 +1859,6 @@ def create_twilio_provider( auth_token: nil, enabled: nil ) - api_path = '/messaging/providers/twilio' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1868,6 +1867,8 @@ def create_twilio_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/twilio' + api_params = { providerId: provider_id, name: name, @@ -1899,7 +1900,7 @@ def create_twilio_provider( # @param [] enabled Set as enabled. # @param [String] account_sid Twilio account secret ID. # @param [String] auth_token Twilio authentication token. - # @param [String] from Sender number. + # @param [String] from Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. # # @return [Provider] def update_twilio_provider( @@ -1910,13 +1911,13 @@ def update_twilio_provider( auth_token: nil, from: nil ) - api_path = '/messaging/providers/twilio/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/twilio/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1958,8 +1959,6 @@ def create_vonage_provider( api_secret: nil, enabled: nil ) - api_path = '/messaging/providers/vonage' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1968,6 +1967,8 @@ def create_vonage_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/vonage' + api_params = { providerId: provider_id, name: name, @@ -2010,13 +2011,13 @@ def update_vonage_provider( api_secret: nil, from: nil ) - api_path = '/messaging/providers/vonage/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/vonage/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -2049,13 +2050,13 @@ def update_vonage_provider( def get_provider( provider_id: ) - api_path = '/messaging/providers/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/{providerId}' + .gsub('{providerId}', provider_id) + api_params = {} api_headers = { @@ -2080,18 +2081,19 @@ def get_provider( def delete_provider( provider_id: ) - api_path = '/messaging/providers/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/{providerId}' + .gsub('{providerId}', provider_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -2142,7 +2144,7 @@ def list_topics( # @param [String] name Topic Name. # @param [Array] subscribe An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. # @param [Integer] qos MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. # # @return [Topic] def create_topic( @@ -2152,8 +2154,6 @@ def create_topic( qos: nil, expiry: nil ) - api_path = '/messaging/topics' - if topic_id.nil? raise Appwrite::Exception.new('Missing required parameter: "topicId"') end @@ -2162,6 +2162,8 @@ def create_topic( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/topics' + api_params = { topicId: topic_id, name: name, @@ -2194,13 +2196,13 @@ def create_topic( def get_topic( topic_id: ) - api_path = '/messaging/topics/{topicId}' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}' + .gsub('{topicId}', topic_id) + api_params = {} api_headers = { @@ -2224,7 +2226,7 @@ def get_topic( # @param [String] name Topic Name. # @param [Array] subscribe An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. # @param [Integer] qos MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. # # @return [Topic] def update_topic( @@ -2234,13 +2236,13 @@ def update_topic( qos: nil, expiry: nil ) - api_path = '/messaging/topics/{topicId}' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}' + .gsub('{topicId}', topic_id) + api_params = { name: name, subscribe: subscribe, @@ -2271,18 +2273,19 @@ def update_topic( def delete_topic( topic_id: ) - api_path = '/messaging/topics/{topicId}' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}' + .gsub('{topicId}', topic_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -2307,13 +2310,13 @@ def list_subscribers( search: nil, total: nil ) - api_path = '/messaging/topics/{topicId}/subscribers' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}/subscribers' + .gsub('{topicId}', topic_id) + api_params = { queries: queries, search: search, @@ -2346,10 +2349,7 @@ def create_subscriber( subscriber_id:, target_id: ) - api_path = '/messaging/topics/{topicId}/subscribers' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end @@ -2361,6 +2361,9 @@ def create_subscriber( raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/messaging/topics/{topicId}/subscribers' + .gsub('{topicId}', topic_id) + api_params = { subscriberId: subscriber_id, targetId: target_id, @@ -2392,18 +2395,18 @@ def get_subscriber( topic_id:, subscriber_id: ) - api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' - .gsub('{topicId}', topic_id) - .gsub('{subscriberId}', subscriber_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end - if subscriber_id.nil? + if subscriber_id.nil? || subscriber_id == '' raise Appwrite::Exception.new('Missing required parameter: "subscriberId"') end + api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .gsub('{topicId}', topic_id) + .gsub('{subscriberId}', subscriber_id) + api_params = {} api_headers = { @@ -2430,23 +2433,24 @@ def delete_subscriber( topic_id:, subscriber_id: ) - api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' - .gsub('{topicId}', topic_id) - .gsub('{subscriberId}', subscriber_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end - if subscriber_id.nil? + if subscriber_id.nil? || subscriber_id == '' raise Appwrite::Exception.new('Missing required parameter: "subscriberId"') end + api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .gsub('{topicId}', topic_id) + .gsub('{subscriberId}', subscriber_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/mongo.rb b/lib/appwrite/services/mongo.rb index 0c95972a..89789257 100644 --- a/lib/appwrite/services/mongo.rb +++ b/lib/appwrite/services/mongo.rb @@ -50,7 +50,7 @@ def list( # @param [Integer] pitr_retention_days Number of days to retain PITR data. # @param [] storage_autoscaling Enable automatic storage expansion when usage exceeds threshold. # @param [Integer] storage_autoscaling_threshold_percent Storage usage percentage (50-95) that triggers automatic expansion. - # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. 0 means no limit. + # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. # # @return [DedicatedDatabase] def create( @@ -69,8 +69,6 @@ def create( storage_autoscaling_threshold_percent: nil, storage_autoscaling_max_gb: nil ) - api_path = '/mongo' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -79,6 +77,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/mongo' + api_params = { databaseId: database_id, name: name, @@ -112,8 +112,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -145,13 +145,13 @@ def list_specifications() def get( database_id: ) - api_path = '/mongo/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update( sql_api_max_bytes: nil, sql_api_timeout_seconds: nil ) - api_path = '/mongo/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, status: status, @@ -275,13 +275,13 @@ def update( def delete( database_id: ) - api_path = '/mongo/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -309,13 +309,13 @@ def list_backups( database_id:, queries: nil ) - api_path = '/mongo/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -345,13 +345,13 @@ def create_backup( database_id:, type: nil ) - api_path = '/mongo/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { type: type, } @@ -381,13 +381,13 @@ def list_backup_policies( database_id:, queries: nil ) - api_path = '/mongo/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -426,10 +426,7 @@ def create_backup_policy( type: nil, enabled: nil ) - api_path = '/mongo/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -449,6 +446,9 @@ def create_backup_policy( raise Appwrite::Exception.new('Missing required parameter: "retention"') end + api_path = '/mongo/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { policyId: policy_id, name: name, @@ -483,18 +483,18 @@ def get_backup_policy( database_id:, policy_id: ) - api_path = '/mongo/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mongo/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -529,18 +529,18 @@ def update_backup_policy( retention: nil, enabled: nil ) - api_path = '/mongo/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mongo/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = { name: name, schedule: schedule, @@ -574,18 +574,18 @@ def delete_backup_policy( database_id:, policy_id: ) - api_path = '/mongo/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mongo/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -626,10 +626,7 @@ def update_backup_storage( prefix: nil, endpoint: nil ) - api_path = '/mongo/{databaseId}/backups/storage' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -649,6 +646,9 @@ def update_backup_storage( raise Appwrite::Exception.new('Missing required parameter: "secretKey"') end + api_path = '/mongo/{databaseId}/backups/storage' + .gsub('{databaseId}', database_id) + api_params = { provider: provider, bucket: bucket, @@ -685,18 +685,18 @@ def get_backup( database_id:, backup_id: ) - api_path = '/mongo/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mongo/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -724,18 +724,18 @@ def delete_backup( database_id:, backup_id: ) - api_path = '/mongo/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mongo/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -761,13 +761,13 @@ def delete_backup( def list_branches( database_id: ) - api_path = '/mongo/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -800,13 +800,13 @@ def create_branch( branch_id: nil, ttl: nil ) - api_path = '/mongo/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = { branchId: branch_id, ttl: ttl, @@ -839,18 +839,18 @@ def delete_branch( database_id:, branch_id: ) - api_path = '/mongo/{databaseId}/branches/{branchId}' - .gsub('{databaseId}', database_id) - .gsub('{branchId}', branch_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if branch_id.nil? + if branch_id.nil? || branch_id == '' raise Appwrite::Exception.new('Missing required parameter: "branchId"') end + api_path = '/mongo/{databaseId}/branches/{branchId}' + .gsub('{databaseId}', database_id) + .gsub('{branchId}', branch_id) + api_params = {} api_headers = { @@ -879,13 +879,13 @@ def delete_branch( def update_credentials( database_id: ) - api_path = '/mongo/{databaseId}/credentials' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/credentials' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -921,13 +921,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/mongo/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -961,10 +961,7 @@ def update_maintenance( day:, hour_utc: ) - api_path = '/mongo/{databaseId}/maintenance' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -976,6 +973,9 @@ def update_maintenance( raise Appwrite::Exception.new('Missing required parameter: "hourUtc"') end + api_path = '/mongo/{databaseId}/maintenance' + .gsub('{databaseId}', database_id) + api_params = { day: day, hourUtc: hour_utc, @@ -1011,10 +1011,7 @@ def create_migration( target_type:, specification: nil ) - api_path = '/mongo/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1022,6 +1019,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "targetType"') end + api_path = '/mongo/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { targetType: target_type, specification: specification, @@ -1059,13 +1059,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/mongo/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1095,13 +1095,13 @@ def list_operations( def get_pitr( database_id: ) - api_path = '/mongo/{databaseId}/pitr' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/pitr' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1127,13 +1127,13 @@ def get_pitr( def get_replicas( database_id: ) - api_path = '/mongo/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1167,13 +1167,13 @@ def list_restorations( limit: nil, offset: nil ) - api_path = '/mongo/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { status: status, type: type, @@ -1214,13 +1214,13 @@ def create_restoration( target_database_id: nil, target_time: nil ) - api_path = '/mongo/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { type: type, backupId: backup_id, @@ -1254,18 +1254,18 @@ def get_restoration( database_id:, restoration_id: ) - api_path = '/mongo/{databaseId}/restorations/{restorationId}' - .gsub('{databaseId}', database_id) - .gsub('{restorationId}', restoration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/mongo/{databaseId}/restorations/{restorationId}' + .gsub('{databaseId}', database_id) + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { @@ -1292,13 +1292,13 @@ def get_restoration( def get_status( database_id: ) - api_path = '/mongo/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1326,10 +1326,7 @@ def create_upgrade( database_id:, target_version: ) - api_path = '/mongo/{databaseId}/upgrades' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1337,6 +1334,9 @@ def create_upgrade( raise Appwrite::Exception.new('Missing required parameter: "targetVersion"') end + api_path = '/mongo/{databaseId}/upgrades' + .gsub('{databaseId}', database_id) + api_params = { targetVersion: target_version, } diff --git a/lib/appwrite/services/mysql.rb b/lib/appwrite/services/mysql.rb index 2e21c83c..065dcbc6 100644 --- a/lib/appwrite/services/mysql.rb +++ b/lib/appwrite/services/mysql.rb @@ -50,7 +50,7 @@ def list( # @param [Integer] pitr_retention_days Number of days to retain PITR data. # @param [] storage_autoscaling Enable automatic storage expansion when usage exceeds threshold. # @param [Integer] storage_autoscaling_threshold_percent Storage usage percentage (50-95) that triggers automatic expansion. - # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. 0 means no limit. + # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. # # @return [DedicatedDatabase] def create( @@ -69,8 +69,6 @@ def create( storage_autoscaling_threshold_percent: nil, storage_autoscaling_max_gb: nil ) - api_path = '/mysql' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -79,6 +77,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/mysql' + api_params = { databaseId: database_id, name: name, @@ -112,8 +112,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -145,13 +145,13 @@ def list_specifications() def get( database_id: ) - api_path = '/mysql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update( sql_api_max_bytes: nil, sql_api_timeout_seconds: nil ) - api_path = '/mysql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, status: status, @@ -275,13 +275,13 @@ def update( def delete( database_id: ) - api_path = '/mysql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -309,13 +309,13 @@ def list_backups( database_id:, queries: nil ) - api_path = '/mysql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -345,13 +345,13 @@ def create_backup( database_id:, type: nil ) - api_path = '/mysql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { type: type, } @@ -381,13 +381,13 @@ def list_backup_policies( database_id:, queries: nil ) - api_path = '/mysql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -426,10 +426,7 @@ def create_backup_policy( type: nil, enabled: nil ) - api_path = '/mysql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -449,6 +446,9 @@ def create_backup_policy( raise Appwrite::Exception.new('Missing required parameter: "retention"') end + api_path = '/mysql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { policyId: policy_id, name: name, @@ -483,18 +483,18 @@ def get_backup_policy( database_id:, policy_id: ) - api_path = '/mysql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mysql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -529,18 +529,18 @@ def update_backup_policy( retention: nil, enabled: nil ) - api_path = '/mysql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mysql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = { name: name, schedule: schedule, @@ -574,18 +574,18 @@ def delete_backup_policy( database_id:, policy_id: ) - api_path = '/mysql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mysql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -626,10 +626,7 @@ def update_backup_storage( prefix: nil, endpoint: nil ) - api_path = '/mysql/{databaseId}/backups/storage' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -649,6 +646,9 @@ def update_backup_storage( raise Appwrite::Exception.new('Missing required parameter: "secretKey"') end + api_path = '/mysql/{databaseId}/backups/storage' + .gsub('{databaseId}', database_id) + api_params = { provider: provider, bucket: bucket, @@ -685,18 +685,18 @@ def get_backup( database_id:, backup_id: ) - api_path = '/mysql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mysql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -724,18 +724,18 @@ def delete_backup( database_id:, backup_id: ) - api_path = '/mysql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mysql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -761,13 +761,13 @@ def delete_backup( def list_branches( database_id: ) - api_path = '/mysql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -800,13 +800,13 @@ def create_branch( branch_id: nil, ttl: nil ) - api_path = '/mysql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = { branchId: branch_id, ttl: ttl, @@ -839,18 +839,18 @@ def delete_branch( database_id:, branch_id: ) - api_path = '/mysql/{databaseId}/branches/{branchId}' - .gsub('{databaseId}', database_id) - .gsub('{branchId}', branch_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if branch_id.nil? + if branch_id.nil? || branch_id == '' raise Appwrite::Exception.new('Missing required parameter: "branchId"') end + api_path = '/mysql/{databaseId}/branches/{branchId}' + .gsub('{databaseId}', database_id) + .gsub('{branchId}', branch_id) + api_params = {} api_headers = { @@ -879,13 +879,13 @@ def delete_branch( def update_credentials( database_id: ) - api_path = '/mysql/{databaseId}/credentials' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/credentials' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -925,10 +925,7 @@ def create_execution( bindings: nil, timeout_seconds: nil ) - api_path = '/mysql/{databaseId}/executions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -936,6 +933,9 @@ def create_execution( raise Appwrite::Exception.new('Missing required parameter: "sql"') end + api_path = '/mysql/{databaseId}/executions' + .gsub('{databaseId}', database_id) + api_params = { sql: sql, bindings: bindings, @@ -975,13 +975,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/mysql/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1015,10 +1015,7 @@ def update_maintenance( day:, hour_utc: ) - api_path = '/mysql/{databaseId}/maintenance' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1030,6 +1027,9 @@ def update_maintenance( raise Appwrite::Exception.new('Missing required parameter: "hourUtc"') end + api_path = '/mysql/{databaseId}/maintenance' + .gsub('{databaseId}', database_id) + api_params = { day: day, hourUtc: hour_utc, @@ -1065,10 +1065,7 @@ def create_migration( target_type:, specification: nil ) - api_path = '/mysql/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1076,6 +1073,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "targetType"') end + api_path = '/mysql/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { targetType: target_type, specification: specification, @@ -1113,13 +1113,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/mysql/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1149,13 +1149,13 @@ def list_operations( def get_pitr( database_id: ) - api_path = '/mysql/{databaseId}/pitr' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/pitr' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1181,13 +1181,13 @@ def get_pitr( def get_pooler( database_id: ) - api_path = '/mysql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1229,13 +1229,13 @@ def update_pooler( pooler_memory_request: nil, pooler_memory_limit: nil ) - api_path = '/mysql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = { mode: mode, maxConnections: max_connections, @@ -1271,13 +1271,13 @@ def update_pooler( def get_replicas( database_id: ) - api_path = '/mysql/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1311,13 +1311,13 @@ def list_restorations( limit: nil, offset: nil ) - api_path = '/mysql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { status: status, type: type, @@ -1358,13 +1358,13 @@ def create_restoration( target_database_id: nil, target_time: nil ) - api_path = '/mysql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { type: type, backupId: backup_id, @@ -1398,18 +1398,18 @@ def get_restoration( database_id:, restoration_id: ) - api_path = '/mysql/{databaseId}/restorations/{restorationId}' - .gsub('{databaseId}', database_id) - .gsub('{restorationId}', restoration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/mysql/{databaseId}/restorations/{restorationId}' + .gsub('{databaseId}', database_id) + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { @@ -1436,13 +1436,13 @@ def get_restoration( def get_status( database_id: ) - api_path = '/mysql/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1470,10 +1470,7 @@ def create_upgrade( database_id:, target_version: ) - api_path = '/mysql/{databaseId}/upgrades' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1481,6 +1478,9 @@ def create_upgrade( raise Appwrite::Exception.new('Missing required parameter: "targetVersion"') end + api_path = '/mysql/{databaseId}/upgrades' + .gsub('{databaseId}', database_id) + api_params = { targetVersion: target_version, } diff --git a/lib/appwrite/services/oauth2.rb b/lib/appwrite/services/oauth2.rb index 33402a28..0571d694 100644 --- a/lib/appwrite/services/oauth2.rb +++ b/lib/appwrite/services/oauth2.rb @@ -22,13 +22,13 @@ def approve( 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_path = '/oauth2/{project_id}/approve' + .gsub('{project_id}', @client.get_config('project')) + api_params = { grant_id: grant_id, authorization_details: authorization_details, @@ -66,7 +66,7 @@ def approve( # @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 [Array] 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. # @@ -137,7 +137,7 @@ def authorize( # @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 [Array] 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. # @@ -198,7 +198,7 @@ def authorize_post( # @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 [Array] 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] @@ -245,13 +245,13 @@ def create_device_authorization( 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_path = '/oauth2/{project_id}/grants' + .gsub('{project_id}', @client.get_config('project')) + api_params = { user_code: user_code, } @@ -280,14 +280,14 @@ def create_grant( def get_grant( grant_id: ) + if grant_id.nil? || grant_id == '' + raise Appwrite::Exception.new('Missing required parameter: "grantId"') + end + 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 = { @@ -398,7 +398,7 @@ def list_organizations( # @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 [Array] 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] @@ -417,9 +417,6 @@ def create_par( 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 @@ -432,6 +429,9 @@ def create_par( raise Appwrite::Exception.new('Missing required parameter: "responseType"') end + api_path = '/oauth2/{project_id}/par' + .gsub('{project_id}', @client.get_config('project')) + api_params = { client_id: client_id, redirect_uri: redirect_uri, @@ -509,13 +509,13 @@ def list_projects( 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_path = '/oauth2/{project_id}/reject' + .gsub('{project_id}', @client.get_config('project')) + api_params = { grant_id: grant_id, } @@ -548,13 +548,13 @@ def revoke( 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_path = '/oauth2/{project_id}/revoke' + .gsub('{project_id}', @client.get_config('project')) + api_params = { token: token, token_type_hint: token_type_hint, @@ -586,7 +586,7 @@ def revoke( # @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 [Array] 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] @@ -602,13 +602,13 @@ def create_token( 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_path = '/oauth2/{project_id}/token' + .gsub('{project_id}', @client.get_config('project')) + api_params = { grant_type: grant_type, code: code, diff --git a/lib/appwrite/services/organization.rb b/lib/appwrite/services/organization.rb index b43b8f29..e086c703 100644 --- a/lib/appwrite/services/organization.rb +++ b/lib/appwrite/services/organization.rb @@ -37,12 +37,12 @@ def get() def update( name: ) - api_path = '/organization' - if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/organization' + api_params = { name: name, } @@ -75,6 +75,7 @@ def delete() api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -129,12 +130,12 @@ 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_path = '/organization/installations' + api_params = { appId: app_id, authorizationDetails: authorization_details, @@ -164,13 +165,13 @@ def create_installation( def get_installation( installation_id: ) - api_path = '/organization/installations/{installationId}' - .gsub('{installationId}', installation_id) - - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -200,13 +201,13 @@ def update_installation( installation_id:, authorization_details: nil ) - api_path = '/organization/installations/{installationId}' - .gsub('{installationId}', installation_id) - - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) + api_params = { authorizationDetails: authorization_details, } @@ -236,216 +237,21 @@ def update_installation( def delete_installation( installation_id: ) - api_path = '/organization/installations/{installationId}' - .gsub('{installationId}', installation_id) - - if installation_id.nil? + if installation_id.nil? || installation_id == '' 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 - # @param [] total When set to false, the total count returned will be 0 and will not be calculated. - # - # @return [KeyList] - def list_keys( - queries: nil, - total: nil - ) - api_path = '/organization/keys' - - api_params = { - queries: queries, - total: total, - } - - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), - "accept": 'application/json', - } - - @client.call( - method: 'GET', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::KeyList - ) - end - - # Create a new organization API key. - # - # @param [String] key_id Key ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - # @param [String] name Key name. Max length: 128 chars. - # @param [Array] scopes Key scopes list. Maximum of 200 scopes are allowed. - # @param [String] expire Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - # - # @return [Key] - def create_key( - key_id:, - name:, - scopes:, - expire: nil - ) - api_path = '/organization/keys' - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') - end - - if name.nil? - raise Appwrite::Exception.new('Missing required parameter: "name"') - end - - if scopes.nil? - raise Appwrite::Exception.new('Missing required parameter: "scopes"') - end - - api_params = { - keyId: key_id, - name: name, - scopes: scopes, - expire: expire, - } - - api_headers = { - "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::Key - ) - end - - # Get a key by its unique ID. This endpoint returns details about a specific - # API key in your organization including its scopes. - # - # @param [String] key_id Key unique ID. - # - # @return [Key] - def get_key( - key_id: - ) - api_path = '/organization/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') - end + api_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) api_params = {} - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), - "accept": 'application/json', - } - - @client.call( - method: 'GET', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::Key - ) - end - - # Update a key by its unique ID. Use this endpoint to update the name, - # scopes, or expiration time of an API key. - # - # @param [String] key_id Key unique ID. - # @param [String] name Key name. Max length: 128 chars. - # @param [Array] scopes Key scopes list. Maximum of 200 scopes are allowed. - # @param [String] expire Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - # - # @return [Key] - def update_key( - key_id:, - name:, - scopes:, - expire: nil - ) - api_path = '/organization/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') - end - - if name.nil? - raise Appwrite::Exception.new('Missing required parameter: "name"') - end - - if scopes.nil? - raise Appwrite::Exception.new('Missing required parameter: "scopes"') - end - - api_params = { - name: name, - scopes: scopes, - expire: expire, - } - api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } - @client.call( - method: 'PUT', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::Key - ) - end - - # Delete a key by its unique ID. Once deleted, the key can no longer be used - # to authenticate API calls. - # - # @param [String] key_id Key unique ID. - # - # @return [] - def delete_key( - key_id: - ) - api_path = '/organization/keys/{keyId}' - .gsub('{keyId}', key_id) - - 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', - } - @client.call( method: 'DELETE', path: api_path, @@ -508,12 +314,12 @@ def create_membership( url: nil, name: nil ) - api_path = '/organization/memberships' - if roles.nil? raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/organization/memberships' + api_params = { email: email, userId: user_id, @@ -546,13 +352,13 @@ def create_membership( def get_membership( membership_id: ) - api_path = '/organization/memberships/{membershipId}' - .gsub('{membershipId}', membership_id) - - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/organization/memberships/{membershipId}' + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { @@ -579,10 +385,7 @@ def update_membership( membership_id:, roles: ) - api_path = '/organization/memberships/{membershipId}' - .gsub('{membershipId}', membership_id) - - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end @@ -590,6 +393,9 @@ def update_membership( raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/organization/memberships/{membershipId}' + .gsub('{membershipId}', membership_id) + api_params = { roles: roles, } @@ -619,18 +425,19 @@ def update_membership( def delete_membership( membership_id: ) - api_path = '/organization/memberships/{membershipId}' - .gsub('{membershipId}', membership_id) - - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/organization/memberships/{membershipId}' + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -688,8 +495,6 @@ def create_project( name:, region: nil ) - api_path = '/organization/projects' - if project_id.nil? raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -698,6 +503,8 @@ def create_project( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/organization/projects' + api_params = { projectId: project_id, name: name, @@ -727,17 +534,18 @@ def create_project( def get_project( project_id: ) - api_path = '/organization/projects/{projectId}' - .gsub('{projectId}', project_id) - - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end + api_path = '/organization/projects/{projectId}' + .gsub('{projectId}', project_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', } @client.call( @@ -759,10 +567,7 @@ def update_project( project_id:, name: ) - api_path = '/organization/projects/{projectId}' - .gsub('{projectId}', project_id) - - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -770,6 +575,9 @@ def update_project( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/organization/projects/{projectId}' + .gsub('{projectId}', project_id) + api_params = { name: name, } @@ -797,18 +605,19 @@ def update_project( def delete_project( project_id: ) - api_path = '/organization/projects/{projectId}' - .gsub('{projectId}', project_id) - - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end + api_path = '/organization/projects/{projectId}' + .gsub('{projectId}', project_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -831,7 +640,7 @@ def list_project_keys( queries: nil, total: nil ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -874,7 +683,7 @@ def create_ephemeral_project_key( scopes:, duration: ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -919,11 +728,11 @@ def get_project_key( project_id:, key_id: ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end @@ -964,11 +773,11 @@ def update_project_key( scopes:, expire: nil ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end @@ -1016,11 +825,11 @@ def delete_project_key( project_id:, key_id: ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end diff --git a/lib/appwrite/services/postgresql.rb b/lib/appwrite/services/postgresql.rb index cd67e74e..1b702cd3 100644 --- a/lib/appwrite/services/postgresql.rb +++ b/lib/appwrite/services/postgresql.rb @@ -50,7 +50,7 @@ def list( # @param [Integer] pitr_retention_days Number of days to retain PITR data. # @param [] storage_autoscaling Enable automatic storage expansion when usage exceeds threshold. # @param [Integer] storage_autoscaling_threshold_percent Storage usage percentage (50-95) that triggers automatic expansion. - # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. 0 means no limit. + # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. # # @return [DedicatedDatabase] def create( @@ -69,8 +69,6 @@ def create( storage_autoscaling_threshold_percent: nil, storage_autoscaling_max_gb: nil ) - api_path = '/postgresql' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -79,6 +77,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/postgresql' + api_params = { databaseId: database_id, name: name, @@ -112,8 +112,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -145,13 +145,13 @@ def list_specifications() def get( database_id: ) - api_path = '/postgresql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update( sql_api_max_bytes: nil, sql_api_timeout_seconds: nil ) - api_path = '/postgresql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, status: status, @@ -275,13 +275,13 @@ def update( def delete( database_id: ) - api_path = '/postgresql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -309,13 +309,13 @@ def list_backups( database_id:, queries: nil ) - api_path = '/postgresql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -345,13 +345,13 @@ def create_backup( database_id:, type: nil ) - api_path = '/postgresql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { type: type, } @@ -381,13 +381,13 @@ def list_backup_policies( database_id:, queries: nil ) - api_path = '/postgresql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -426,10 +426,7 @@ def create_backup_policy( type: nil, enabled: nil ) - api_path = '/postgresql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -449,6 +446,9 @@ def create_backup_policy( raise Appwrite::Exception.new('Missing required parameter: "retention"') end + api_path = '/postgresql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { policyId: policy_id, name: name, @@ -483,18 +483,18 @@ def get_backup_policy( database_id:, policy_id: ) - api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -529,18 +529,18 @@ def update_backup_policy( retention: nil, enabled: nil ) - api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = { name: name, schedule: schedule, @@ -574,18 +574,18 @@ def delete_backup_policy( database_id:, policy_id: ) - api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -626,10 +626,7 @@ def update_backup_storage( prefix: nil, endpoint: nil ) - api_path = '/postgresql/{databaseId}/backups/storage' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -649,6 +646,9 @@ def update_backup_storage( raise Appwrite::Exception.new('Missing required parameter: "secretKey"') end + api_path = '/postgresql/{databaseId}/backups/storage' + .gsub('{databaseId}', database_id) + api_params = { provider: provider, bucket: bucket, @@ -685,18 +685,18 @@ def get_backup( database_id:, backup_id: ) - api_path = '/postgresql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/postgresql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -724,18 +724,18 @@ def delete_backup( database_id:, backup_id: ) - api_path = '/postgresql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/postgresql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -761,13 +761,13 @@ def delete_backup( def list_branches( database_id: ) - api_path = '/postgresql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -800,13 +800,13 @@ def create_branch( branch_id: nil, ttl: nil ) - api_path = '/postgresql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = { branchId: branch_id, ttl: ttl, @@ -839,18 +839,18 @@ def delete_branch( database_id:, branch_id: ) - api_path = '/postgresql/{databaseId}/branches/{branchId}' - .gsub('{databaseId}', database_id) - .gsub('{branchId}', branch_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if branch_id.nil? + if branch_id.nil? || branch_id == '' raise Appwrite::Exception.new('Missing required parameter: "branchId"') end + api_path = '/postgresql/{databaseId}/branches/{branchId}' + .gsub('{databaseId}', database_id) + .gsub('{branchId}', branch_id) + api_params = {} api_headers = { @@ -879,13 +879,13 @@ def delete_branch( def update_credentials( database_id: ) - api_path = '/postgresql/{databaseId}/credentials' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/credentials' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -925,10 +925,7 @@ def create_execution( bindings: nil, timeout_seconds: nil ) - api_path = '/postgresql/{databaseId}/executions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -936,6 +933,9 @@ def create_execution( raise Appwrite::Exception.new('Missing required parameter: "sql"') end + api_path = '/postgresql/{databaseId}/executions' + .gsub('{databaseId}', database_id) + api_params = { sql: sql, bindings: bindings, @@ -965,13 +965,13 @@ def create_execution( def list_extensions( database_id: ) - api_path = '/postgresql/{databaseId}/extensions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/extensions' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -999,10 +999,7 @@ def create_extension( database_id:, name: ) - api_path = '/postgresql/{databaseId}/extensions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1010,6 +1007,9 @@ def create_extension( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/postgresql/{databaseId}/extensions' + .gsub('{databaseId}', database_id) + api_params = { name: name, } @@ -1040,18 +1040,18 @@ def delete_extension( database_id:, extension_name: ) - api_path = '/postgresql/{databaseId}/extensions/{extensionName}' - .gsub('{databaseId}', database_id) - .gsub('{extensionName}', extension_name) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if extension_name.nil? + if extension_name.nil? || extension_name == '' raise Appwrite::Exception.new('Missing required parameter: "extensionName"') end + api_path = '/postgresql/{databaseId}/extensions/{extensionName}' + .gsub('{databaseId}', database_id) + .gsub('{extensionName}', extension_name) + api_params = {} api_headers = { @@ -1087,13 +1087,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/postgresql/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1127,10 +1127,7 @@ def update_maintenance( day:, hour_utc: ) - api_path = '/postgresql/{databaseId}/maintenance' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1142,6 +1139,9 @@ def update_maintenance( raise Appwrite::Exception.new('Missing required parameter: "hourUtc"') end + api_path = '/postgresql/{databaseId}/maintenance' + .gsub('{databaseId}', database_id) + api_params = { day: day, hourUtc: hour_utc, @@ -1177,10 +1177,7 @@ def create_migration( target_type:, specification: nil ) - api_path = '/postgresql/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1188,6 +1185,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "targetType"') end + api_path = '/postgresql/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { targetType: target_type, specification: specification, @@ -1225,13 +1225,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/postgresql/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1261,13 +1261,13 @@ def list_operations( def get_pitr( database_id: ) - api_path = '/postgresql/{databaseId}/pitr' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/pitr' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1293,13 +1293,13 @@ def get_pitr( def get_pooler( database_id: ) - api_path = '/postgresql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1341,13 +1341,13 @@ def update_pooler( pooler_memory_request: nil, pooler_memory_limit: nil ) - api_path = '/postgresql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = { mode: mode, maxConnections: max_connections, @@ -1383,13 +1383,13 @@ def update_pooler( def get_replicas( database_id: ) - api_path = '/postgresql/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1423,13 +1423,13 @@ def list_restorations( limit: nil, offset: nil ) - api_path = '/postgresql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { status: status, type: type, @@ -1470,13 +1470,13 @@ def create_restoration( target_database_id: nil, target_time: nil ) - api_path = '/postgresql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { type: type, backupId: backup_id, @@ -1510,18 +1510,18 @@ def get_restoration( database_id:, restoration_id: ) - api_path = '/postgresql/{databaseId}/restorations/{restorationId}' - .gsub('{databaseId}', database_id) - .gsub('{restorationId}', restoration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/postgresql/{databaseId}/restorations/{restorationId}' + .gsub('{databaseId}', database_id) + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { @@ -1548,13 +1548,13 @@ def get_restoration( def get_status( database_id: ) - api_path = '/postgresql/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1582,10 +1582,7 @@ def create_upgrade( database_id:, target_version: ) - api_path = '/postgresql/{databaseId}/upgrades' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1593,6 +1590,9 @@ def create_upgrade( raise Appwrite::Exception.new('Missing required parameter: "targetVersion"') end + api_path = '/postgresql/{databaseId}/upgrades' + .gsub('{databaseId}', database_id) + api_params = { targetVersion: target_version, } diff --git a/lib/appwrite/services/presences.rb b/lib/appwrite/services/presences.rb index 01a022ed..a90a17d2 100644 --- a/lib/appwrite/services/presences.rb +++ b/lib/appwrite/services/presences.rb @@ -51,13 +51,13 @@ def list( def get( presence_id: ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = {} api_headers = { @@ -93,10 +93,7 @@ def upsert( expires_at: nil, metadata: nil ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end @@ -108,6 +105,9 @@ def upsert( raise Appwrite::Exception.new('Missing required parameter: "status"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = { userId: user_id, status: status, @@ -153,10 +153,7 @@ def update( permissions: nil, purge: nil ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end @@ -164,6 +161,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = { userId: user_id, status: status, @@ -197,18 +197,19 @@ def update( def delete( presence_id: ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/project.rb b/lib/appwrite/services/project.rb index 21ff2eb5..e5bc96b9 100644 --- a/lib/appwrite/services/project.rb +++ b/lib/appwrite/services/project.rb @@ -17,6 +17,7 @@ def get() api_headers = { "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', } @client.call( @@ -40,6 +41,7 @@ def delete() api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -53,7 +55,7 @@ def delete() # Update properties of a specific auth method. Use this endpoint to enable or # disable a method in your project. # - # @param [ProjectAuthMethodId] method_id Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone + # @param [ProjectAuthMethodId] method_id Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey # @param [] enabled Auth method status. # # @return [Project] @@ -61,9 +63,6 @@ def update_auth_method( method_id:, enabled: ) - api_path = '/project/auth-methods/{methodId}' - .gsub('{methodId}', method_id) - if method_id.nil? raise Appwrite::Exception.new('Missing required parameter: "methodId"') end @@ -72,6 +71,9 @@ def update_auth_method( raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/auth-methods/{methodId}' + .gsub('{methodId}', method_id) + api_params = { enabled: enabled, } @@ -173,7 +175,7 @@ def create_environment( def get_environment( environment_id: ) - if environment_id.nil? + if environment_id.nil? || environment_id == '' raise Appwrite::Exception.new('Missing required parameter: "environmentId"') end @@ -206,7 +208,7 @@ def update_environment( environment_id:, name: ) - if environment_id.nil? + if environment_id.nil? || environment_id == '' raise Appwrite::Exception.new('Missing required parameter: "environmentId"') end @@ -244,7 +246,7 @@ def update_environment( def delete_environment( environment_id: ) - if environment_id.nil? + if environment_id.nil? || environment_id == '' raise Appwrite::Exception.new('Missing required parameter: "environmentId"') end @@ -312,8 +314,6 @@ def create_ephemeral_key( scopes:, duration: ) - api_path = '/project/keys/ephemeral' - if scopes.nil? raise Appwrite::Exception.new('Missing required parameter: "scopes"') end @@ -322,6 +322,8 @@ def create_ephemeral_key( raise Appwrite::Exception.new('Missing required parameter: "duration"') end + api_path = '/project/keys/ephemeral' + api_params = { scopes: scopes, duration: duration, @@ -350,13 +352,13 @@ def create_ephemeral_key( def get_key( key_id: ) - api_path = '/project/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/project/keys/{keyId}' + .gsub('{keyId}', key_id) + api_params = {} api_headers = { @@ -388,10 +390,7 @@ def update_key( scopes:, expire: nil ) - api_path = '/project/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end @@ -403,6 +402,9 @@ def update_key( raise Appwrite::Exception.new('Missing required parameter: "scopes"') end + api_path = '/project/keys/{keyId}' + .gsub('{keyId}', key_id) + api_params = { name: name, scopes: scopes, @@ -433,18 +435,19 @@ def update_key( def delete_key( key_id: ) - api_path = '/project/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/project/keys/{keyId}' + .gsub('{keyId}', key_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -464,12 +467,12 @@ def delete_key( def update_labels( labels: ) - api_path = '/project/labels' - if labels.nil? raise Appwrite::Exception.new('Missing required parameter: "labels"') end + api_path = '/project/labels' + api_params = { labels: labels, } @@ -532,8 +535,6 @@ def create_mock_phone( number:, otp: ) - api_path = '/project/mock-phones' - if number.nil? raise Appwrite::Exception.new('Missing required parameter: "number"') end @@ -542,6 +543,8 @@ def create_mock_phone( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/project/mock-phones' + api_params = { number: number, otp: otp, @@ -571,13 +574,13 @@ def create_mock_phone( def get_mock_phone( number: ) - api_path = '/project/mock-phones/{number}' - .gsub('{number}', number) - - if number.nil? + if number.nil? || number == '' raise Appwrite::Exception.new('Missing required parameter: "number"') end + api_path = '/project/mock-phones/{number}' + .gsub('{number}', number) + api_params = {} api_headers = { @@ -605,10 +608,7 @@ def update_mock_phone( number:, otp: ) - api_path = '/project/mock-phones/{number}' - .gsub('{number}', number) - - if number.nil? + if number.nil? || number == '' raise Appwrite::Exception.new('Missing required parameter: "number"') end @@ -616,6 +616,9 @@ def update_mock_phone( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/project/mock-phones/{number}' + .gsub('{number}', number) + api_params = { otp: otp, } @@ -644,18 +647,19 @@ def update_mock_phone( def delete_mock_phone( number: ) - api_path = '/project/mock-phones/{number}' - .gsub('{number}', number) - - if number.nil? + if number.nil? || number == '' raise Appwrite::Exception.new('Missing required parameter: "number"') end + api_path = '/project/mock-phones/{number}' + .gsub('{number}', number) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -737,8 +741,6 @@ def update_o_auth2_server( default_scopes: nil, installation_scopes: nil ) - api_path = '/project/oauth2-server' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end @@ -747,6 +749,8 @@ def update_o_auth2_server( raise Appwrite::Exception.new('Missing required parameter: "authorizationUrl"') end + api_path = '/project/oauth2-server' + api_params = { enabled: enabled, authorizationUrl: authorization_url, @@ -1597,23 +1601,23 @@ def update_o_auth2_hugging_face( # # @param [String] client_id 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de # @param [String] client_secret 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled - # @param [Array] prompt Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # @param [Array] prompt Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. # # @return [OAuth2Kakao] def update_o_auth2_kakao( client_id: nil, client_secret: nil, - prompt: nil, - enabled: nil + enabled: nil, + prompt: nil ) api_path = '/project/oauth2/kakao' api_params = { clientId: client_id, clientSecret: client_secret, - prompt: prompt, enabled: enabled, + prompt: prompt, } api_headers = { @@ -2595,13 +2599,13 @@ def update_o_auth2_zoom( def get_o_auth2_provider( provider_id: ) - api_path = '/project/oauth2/{providerId}' - .gsub('{providerId}', provider_id) - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/project/oauth2/{providerId}' + .gsub('{providerId}', provider_id) + api_params = {} api_headers = { @@ -2901,8 +2905,6 @@ def create_android_platform( application_id:, fingerprints: nil ) - api_path = '/project/platforms/android' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -2915,6 +2917,8 @@ def create_android_platform( raise Appwrite::Exception.new('Missing required parameter: "applicationId"') end + api_path = '/project/platforms/android' + api_params = { platformId: platform_id, name: name, @@ -2938,7 +2942,7 @@ def create_android_platform( end # Update an Android platform by its unique ID. Use this endpoint to update - # the platform's name or application ID. + # the platform's name, application ID or signing certificate fingerprints. # # @param [String] platform_id Platform ID. # @param [String] name Platform name. Max length: 128 chars. @@ -2952,10 +2956,7 @@ def update_android_platform( application_id:, fingerprints: nil ) - api_path = '/project/platforms/android/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -2967,6 +2968,9 @@ def update_android_platform( raise Appwrite::Exception.new('Missing required parameter: "applicationId"') end + api_path = '/project/platforms/android/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, applicationId: application_id, @@ -3002,8 +3006,6 @@ def create_apple_platform( name:, bundle_identifier: ) - api_path = '/project/platforms/apple' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3016,6 +3018,8 @@ def create_apple_platform( raise Appwrite::Exception.new('Missing required parameter: "bundleIdentifier"') end + api_path = '/project/platforms/apple' + api_params = { platformId: platform_id, name: name, @@ -3050,10 +3054,7 @@ def update_apple_platform( name:, bundle_identifier: ) - api_path = '/project/platforms/apple/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3065,6 +3066,9 @@ def update_apple_platform( raise Appwrite::Exception.new('Missing required parameter: "bundleIdentifier"') end + api_path = '/project/platforms/apple/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, bundleIdentifier: bundle_identifier, @@ -3099,8 +3103,6 @@ def create_linux_platform( name:, package_name: ) - api_path = '/project/platforms/linux' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3113,6 +3115,8 @@ def create_linux_platform( raise Appwrite::Exception.new('Missing required parameter: "packageName"') end + api_path = '/project/platforms/linux' + api_params = { platformId: platform_id, name: name, @@ -3147,10 +3151,7 @@ def update_linux_platform( name:, package_name: ) - api_path = '/project/platforms/linux/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3162,6 +3163,9 @@ def update_linux_platform( raise Appwrite::Exception.new('Missing required parameter: "packageName"') end + api_path = '/project/platforms/linux/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, packageName: package_name, @@ -3196,8 +3200,6 @@ def create_web_platform( name:, hostname: ) - api_path = '/project/platforms/web' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3210,6 +3212,8 @@ def create_web_platform( raise Appwrite::Exception.new('Missing required parameter: "hostname"') end + api_path = '/project/platforms/web' + api_params = { platformId: platform_id, name: name, @@ -3244,10 +3248,7 @@ def update_web_platform( name:, hostname: ) - api_path = '/project/platforms/web/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3259,6 +3260,9 @@ def update_web_platform( raise Appwrite::Exception.new('Missing required parameter: "hostname"') end + api_path = '/project/platforms/web/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, hostname: hostname, @@ -3293,8 +3297,6 @@ def create_windows_platform( name:, package_identifier_name: ) - api_path = '/project/platforms/windows' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3307,6 +3309,8 @@ def create_windows_platform( raise Appwrite::Exception.new('Missing required parameter: "packageIdentifierName"') end + api_path = '/project/platforms/windows' + api_params = { platformId: platform_id, name: name, @@ -3341,10 +3345,7 @@ def update_windows_platform( name:, package_identifier_name: ) - api_path = '/project/platforms/windows/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3356,6 +3357,9 @@ def update_windows_platform( raise Appwrite::Exception.new('Missing required parameter: "packageIdentifierName"') end + api_path = '/project/platforms/windows/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, packageIdentifierName: package_identifier_name, @@ -3385,13 +3389,13 @@ def update_windows_platform( def get_platform( platform_id: ) - api_path = '/project/platforms/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end + api_path = '/project/platforms/{platformId}' + .gsub('{platformId}', platform_id) + api_params = {} api_headers = { @@ -3447,18 +3451,19 @@ def get_platform( def delete_platform( platform_id: ) - api_path = '/project/platforms/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end + api_path = '/project/platforms/{platformId}' + .gsub('{platformId}', platform_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3509,12 +3514,12 @@ def list_policies( def update_deny_aliased_email_policy( enabled: ) - api_path = '/project/policies/deny-aliased-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-aliased-email' + api_params = { enabled: enabled, } @@ -3543,12 +3548,12 @@ def update_deny_aliased_email_policy( def update_deny_corporate_email_policy( enabled: ) - api_path = '/project/policies/deny-corporate-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-corporate-email' + api_params = { enabled: enabled, } @@ -3577,12 +3582,12 @@ def update_deny_corporate_email_policy( def update_deny_disposable_email_policy( enabled: ) - api_path = '/project/policies/deny-disposable-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-disposable-email' + api_params = { enabled: enabled, } @@ -3611,12 +3616,12 @@ def update_deny_disposable_email_policy( def update_deny_free_email_policy( enabled: ) - api_path = '/project/policies/deny-free-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-free-email' + api_params = { enabled: enabled, } @@ -3772,12 +3777,12 @@ def update_passkey_policy( def update_password_dictionary_policy( enabled: ) - api_path = '/project/policies/password-dictionary' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/password-dictionary' + api_params = { enabled: enabled, } @@ -3813,12 +3818,12 @@ def update_password_dictionary_policy( def update_password_history_policy( total: ) - api_path = '/project/policies/password-history' - if total.nil? raise Appwrite::Exception.new('Missing required parameter: "total"') end + api_path = '/project/policies/password-history' + api_params = { total: total, } @@ -3849,12 +3854,12 @@ def update_password_history_policy( def update_password_personal_data_policy( enabled: ) - api_path = '/project/policies/password-personal-data' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/password-personal-data' + api_params = { enabled: enabled, } @@ -4003,12 +4008,12 @@ def update_password_strength_policy( def update_session_alert_policy( enabled: ) - api_path = '/project/policies/session-alert' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/session-alert' + api_params = { enabled: enabled, } @@ -4037,12 +4042,12 @@ def update_session_alert_policy( def update_session_duration_policy( duration: ) - api_path = '/project/policies/session-duration' - if duration.nil? raise Appwrite::Exception.new('Missing required parameter: "duration"') end + api_path = '/project/policies/session-duration' + api_params = { duration: duration, } @@ -4072,12 +4077,12 @@ def update_session_duration_policy( def update_session_invalidation_policy( enabled: ) - api_path = '/project/policies/session-invalidation' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/session-invalidation' + api_params = { enabled: enabled, } @@ -4106,12 +4111,12 @@ def update_session_invalidation_policy( def update_session_limit_policy( total: ) - api_path = '/project/policies/session-limit' - if total.nil? raise Appwrite::Exception.new('Missing required parameter: "total"') end + api_path = '/project/policies/session-limit' + api_params = { total: total, } @@ -4141,12 +4146,12 @@ def update_session_limit_policy( def update_user_limit_policy( total: ) - api_path = '/project/policies/user-limit' - if total.nil? raise Appwrite::Exception.new('Missing required parameter: "total"') end + api_path = '/project/policies/user-limit' + api_params = { total: total, } @@ -4169,19 +4174,19 @@ def update_user_limit_policy( # Get a policy by its unique ID. This endpoint returns the current # configuration for the requested project policy. # - # @param [ProjectPolicyId] policy_id Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + # @param [ProjectPolicyId] policy_id Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. # # @return [PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordStrength, PolicyPasswordPersonalData, PolicyPasswordPwned, PolicyPasswordRotation, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy, PolicyMfaFactors, PolicyDenyAliasedEmail, PolicyDenyDisposableEmail, PolicyDenyFreeEmail, PolicyDenyCorporateEmail, PolicyPasskey] def get_policy( policy_id: ) - api_path = '/project/policies/{policyId}' - .gsub('{policyId}', policy_id) - if policy_id.nil? raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/project/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -4304,9 +4309,6 @@ def update_protocol( protocol_id:, enabled: ) - api_path = '/project/protocols/{protocolId}' - .gsub('{protocolId}', protocol_id) - if protocol_id.nil? raise Appwrite::Exception.new('Missing required parameter: "protocolId"') end @@ -4315,6 +4317,9 @@ def update_protocol( raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/protocols/{protocolId}' + .gsub('{protocolId}', protocol_id) + api_params = { enabled: enabled, } @@ -4345,9 +4350,6 @@ def update_service( service_id:, enabled: ) - api_path = '/project/services/{serviceId}' - .gsub('{serviceId}', service_id) - if service_id.nil? raise Appwrite::Exception.new('Missing required parameter: "serviceId"') end @@ -4356,6 +4358,9 @@ def update_service( raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/services/{serviceId}' + .gsub('{serviceId}', service_id) + api_params = { enabled: enabled, } @@ -4441,12 +4446,12 @@ def update_smtp( def create_smtp_test( emails: ) - api_path = '/project/smtp/tests' - if emails.nil? raise Appwrite::Exception.new('Missing required parameter: "emails"') end + api_path = '/project/smtp/tests' + api_params = { emails: emails, } @@ -4454,6 +4459,7 @@ def create_smtp_test( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -4500,7 +4506,7 @@ def list_email_templates( # Update a custom email template for the specified locale and type. Use this # endpoint to modify the content of your email templates. # - # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery # @param [ProjectEmailTemplateLocale] locale Custom email template locale. If left empty, the fallback locale (en) will be used. # @param [String] subject Subject of the email template. Can be up to 255 characters. # @param [String] message Plain or HTML body of the email template message. Can be up to 10MB of content. @@ -4520,12 +4526,12 @@ def update_email_template( reply_to_email: nil, reply_to_name: nil ) - api_path = '/project/templates/email' - if template_id.nil? raise Appwrite::Exception.new('Missing required parameter: "templateId"') end + api_path = '/project/templates/email' + api_params = { templateId: template_id, locale: locale, @@ -4556,7 +4562,7 @@ def update_email_template( # endpoint returns the template content, subject, and other configuration # details. # - # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery # @param [ProjectEmailTemplateLocale] locale Custom email template locale. If left empty, the fallback locale (en) will be used. # # @return [EmailTemplate] @@ -4564,13 +4570,13 @@ def get_email_template( template_id:, locale: nil ) - api_path = '/project/templates/email/{templateId}' - .gsub('{templateId}', template_id) - if template_id.nil? raise Appwrite::Exception.new('Missing required parameter: "templateId"') end + api_path = '/project/templates/email/{templateId}' + .gsub('{templateId}', template_id) + api_params = { locale: locale, } @@ -4635,8 +4641,6 @@ def create_variable( value:, secret: nil ) - api_path = '/project/variables' - if variable_id.nil? raise Appwrite::Exception.new('Missing required parameter: "variableId"') end @@ -4649,6 +4653,8 @@ def create_variable( raise Appwrite::Exception.new('Missing required parameter: "value"') end + api_path = '/project/variables' + api_params = { variableId: variable_id, key: key, @@ -4679,13 +4685,13 @@ def create_variable( def get_variable( variable_id: ) - api_path = '/project/variables/{variableId}' - .gsub('{variableId}', variable_id) - - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/project/variables/{variableId}' + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { @@ -4716,13 +4722,13 @@ def update_variable( value: nil, secret: nil ) - api_path = '/project/variables/{variableId}' - .gsub('{variableId}', variable_id) - - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/project/variables/{variableId}' + .gsub('{variableId}', variable_id) + api_params = { key: key, value: value, @@ -4752,18 +4758,19 @@ def update_variable( def delete_variable( variable_id: ) - api_path = '/project/variables/{variableId}' - .gsub('{variableId}', variable_id) - - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/project/variables/{variableId}' + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/proxy.rb b/lib/appwrite/services/proxy.rb index 48d11c6d..ddacf0e4 100644 --- a/lib/appwrite/services/proxy.rb +++ b/lib/appwrite/services/proxy.rb @@ -12,6 +12,8 @@ def initialize(client) # Depending on type, the invalidation purges a single cache tag, a single URL # path, or all cached content for the domain. # + # Domains that route to a function do not support cache invalidation. + # # @param [String] domain Domain name. # @param [InvalidationType] type Type of reference passed. Allowed values are: tag, path, all # @param [String] reference Reference to invalidate. Depending on type this can be: cache tag name (up to 128 characters), URL path (up to 2048 characters). Not required when type is all. @@ -22,8 +24,6 @@ def create_invalidation( type:, reference: nil ) - api_path = '/proxy/invalidations' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -32,6 +32,8 @@ def create_invalidation( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/proxy/invalidations' + api_params = { domain: domain, type: type, @@ -96,12 +98,12 @@ def list_rules( def create_api_rule( domain: ) - api_path = '/proxy/rules/api' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end + api_path = '/proxy/rules/api' + api_params = { domain: domain, } @@ -136,8 +138,6 @@ def create_function_rule( function_id:, branch: nil ) - api_path = '/proxy/rules/function' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -146,6 +146,8 @@ def create_function_rule( raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/proxy/rules/function' + api_params = { domain: domain, functionId: function_id, @@ -187,8 +189,6 @@ def create_redirect_rule( resource_id:, resource_type: ) - api_path = '/proxy/rules/redirect' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -209,6 +209,8 @@ def create_redirect_rule( raise Appwrite::Exception.new('Missing required parameter: "resourceType"') end + api_path = '/proxy/rules/redirect' + api_params = { domain: domain, url: url, @@ -247,8 +249,6 @@ def create_site_rule( site_id:, branch: nil ) - api_path = '/proxy/rules/site' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -257,6 +257,8 @@ def create_site_rule( raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/proxy/rules/site' + api_params = { domain: domain, siteId: site_id, @@ -286,13 +288,13 @@ def create_site_rule( def get_rule( rule_id: ) - api_path = '/proxy/rules/{ruleId}' - .gsub('{ruleId}', rule_id) - - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end + api_path = '/proxy/rules/{ruleId}' + .gsub('{ruleId}', rule_id) + api_params = {} api_headers = { @@ -317,18 +319,19 @@ def get_rule( def delete_rule( rule_id: ) - api_path = '/proxy/rules/{ruleId}' - .gsub('{ruleId}', rule_id) - - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end + api_path = '/proxy/rules/{ruleId}' + .gsub('{ruleId}', rule_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -350,13 +353,13 @@ def delete_rule( def update_rule_status( rule_id: ) - api_path = '/proxy/rules/{ruleId}/status' - .gsub('{ruleId}', rule_id) - - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end + api_path = '/proxy/rules/{ruleId}/status' + .gsub('{ruleId}', rule_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/sites.rb b/lib/appwrite/services/sites.rb index 46a830f2..9a7d793e 100644 --- a/lib/appwrite/services/sites.rb +++ b/lib/appwrite/services/sites.rb @@ -95,8 +95,6 @@ def create( deployment_retention: nil, scopes: nil ) - api_path = '/sites' - if site_id.nil? raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -113,6 +111,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "buildRuntime"') end + api_path = '/sites' + api_params = { siteId: site_id, name: name, @@ -223,13 +223,13 @@ def list_specifications( def get( site_id: ) - api_path = '/sites/{siteId}' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}' + .gsub('{siteId}', site_id) + api_params = {} api_headers = { @@ -300,10 +300,7 @@ def update( deployment_retention: nil, scopes: nil ) - api_path = '/sites/{siteId}' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -315,6 +312,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "framework"') end + api_path = '/sites/{siteId}' + .gsub('{siteId}', site_id) + api_params = { name: name, framework: framework, @@ -364,18 +364,19 @@ def update( def delete( site_id: ) - api_path = '/sites/{siteId}' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}' + .gsub('{siteId}', site_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -397,10 +398,7 @@ def update_site_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployment' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -408,6 +406,9 @@ def update_site_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployment' + .gsub('{siteId}', site_id) + api_params = { deploymentId: deployment_id, } @@ -442,13 +443,13 @@ def list_deployments( search: nil, total: nil ) - api_path = '/sites/{siteId}/deployments' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}/deployments' + .gsub('{siteId}', site_id) + api_params = { queries: queries, search: search, @@ -490,10 +491,7 @@ def create_deployment( activate: nil, on_progress: nil ) - api_path = '/sites/{siteId}/deployments' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -501,6 +499,9 @@ def create_deployment( raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/sites/{siteId}/deployments' + .gsub('{siteId}', site_id) + api_params = { installCommand: install_command, buildCommand: build_command, @@ -525,6 +526,7 @@ def create_deployment( param_name: param_name, id_param_name: id_param_name, on_progress: on_progress, + method: 'POST', response_type: Models::Deployment ) end @@ -543,10 +545,7 @@ def create_duplicate_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/duplicate' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -554,6 +553,9 @@ def create_duplicate_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/duplicate' + .gsub('{siteId}', site_id) + api_params = { deploymentId: deployment_id, } @@ -597,10 +599,7 @@ def create_template_deployment( reference:, activate: nil ) - api_path = '/sites/{siteId}/deployments/template' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -624,6 +623,9 @@ def create_template_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/sites/{siteId}/deployments/template' + .gsub('{siteId}', site_id) + api_params = { repository: repository, owner: owner, @@ -664,10 +666,7 @@ def create_vcs_deployment( reference:, activate: nil ) - api_path = '/sites/{siteId}/deployments/vcs' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -679,6 +678,9 @@ def create_vcs_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/sites/{siteId}/deployments/vcs' + .gsub('{siteId}', site_id) + api_params = { type: type, reference: reference, @@ -710,18 +712,18 @@ def get_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/{deploymentId}' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -748,23 +750,24 @@ def delete_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/{deploymentId}' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -791,18 +794,18 @@ def get_deployment_download( type: nil, token: nil ) - api_path = '/sites/{siteId}/deployments/{deploymentId}/download' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}/download' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = { type: type, token: token, @@ -835,18 +838,18 @@ def update_deployment_status( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/{deploymentId}/status' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}/status' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -877,13 +880,13 @@ def list_logs( queries: nil, total: nil ) - api_path = '/sites/{siteId}/logs' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}/logs' + .gsub('{siteId}', site_id) + api_params = { queries: queries, total: total, @@ -913,18 +916,18 @@ def get_log( site_id:, log_id: ) - api_path = '/sites/{siteId}/logs/{logId}' - .gsub('{siteId}', site_id) - .gsub('{logId}', log_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if log_id.nil? + if log_id.nil? || log_id == '' raise Appwrite::Exception.new('Missing required parameter: "logId"') end + api_path = '/sites/{siteId}/logs/{logId}' + .gsub('{siteId}', site_id) + .gsub('{logId}', log_id) + api_params = {} api_headers = { @@ -951,18 +954,18 @@ def delete_log( site_id:, log_id: ) - api_path = '/sites/{siteId}/logs/{logId}' - .gsub('{siteId}', site_id) - .gsub('{logId}', log_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if log_id.nil? + if log_id.nil? || log_id == '' raise Appwrite::Exception.new('Missing required parameter: "logId"') end + api_path = '/sites/{siteId}/logs/{logId}' + .gsub('{siteId}', site_id) + .gsub('{logId}', log_id) + api_params = {} api_headers = { @@ -991,13 +994,13 @@ def list_variables( queries: nil, total: nil ) - api_path = '/sites/{siteId}/variables' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}/variables' + .gsub('{siteId}', site_id) + api_params = { queries: queries, total: total, @@ -1034,10 +1037,7 @@ def create_variable( value:, secret: nil ) - api_path = '/sites/{siteId}/variables' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -1053,6 +1053,9 @@ def create_variable( raise Appwrite::Exception.new('Missing required parameter: "value"') end + api_path = '/sites/{siteId}/variables' + .gsub('{siteId}', site_id) + api_params = { variableId: variable_id, key: key, @@ -1085,18 +1088,18 @@ def get_variable( site_id:, variable_id: ) - api_path = '/sites/{siteId}/variables/{variableId}' - .gsub('{siteId}', site_id) - .gsub('{variableId}', variable_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/sites/{siteId}/variables/{variableId}' + .gsub('{siteId}', site_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { @@ -1129,18 +1132,18 @@ def update_variable( value: nil, secret: nil ) - api_path = '/sites/{siteId}/variables/{variableId}' - .gsub('{siteId}', site_id) - .gsub('{variableId}', variable_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/sites/{siteId}/variables/{variableId}' + .gsub('{siteId}', site_id) + .gsub('{variableId}', variable_id) + api_params = { key: key, value: value, @@ -1172,23 +1175,24 @@ def delete_variable( site_id:, variable_id: ) - api_path = '/sites/{siteId}/variables/{variableId}' - .gsub('{siteId}', site_id) - .gsub('{variableId}', variable_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/sites/{siteId}/variables/{variableId}' + .gsub('{siteId}', site_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/storage.rb b/lib/appwrite/services/storage.rb index 18389d90..1938edd1 100644 --- a/lib/appwrite/services/storage.rb +++ b/lib/appwrite/services/storage.rb @@ -69,8 +69,6 @@ def create_bucket( antivirus: nil, transformations: nil ) - api_path = '/storage/buckets' - if bucket_id.nil? raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end @@ -79,6 +77,8 @@ def create_bucket( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/storage/buckets' + api_params = { bucketId: bucket_id, name: name, @@ -117,13 +117,13 @@ def create_bucket( def get_bucket( bucket_id: ) - api_path = '/storage/buckets/{bucketId}' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end + api_path = '/storage/buckets/{bucketId}' + .gsub('{bucketId}', bucket_id) + api_params = {} api_headers = { @@ -168,10 +168,7 @@ def update_bucket( antivirus: nil, transformations: nil ) - api_path = '/storage/buckets/{bucketId}' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end @@ -179,6 +176,9 @@ def update_bucket( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/storage/buckets/{bucketId}' + .gsub('{bucketId}', bucket_id) + api_params = { name: name, permissions: permissions, @@ -215,18 +215,19 @@ def update_bucket( def delete_bucket( bucket_id: ) - api_path = '/storage/buckets/{bucketId}' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end + api_path = '/storage/buckets/{bucketId}' + .gsub('{bucketId}', bucket_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -252,13 +253,13 @@ def list_files( search: nil, total: nil ) - api_path = '/storage/buckets/{bucketId}/files' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end + api_path = '/storage/buckets/{bucketId}/files' + .gsub('{bucketId}', bucket_id) + api_params = { queries: queries, search: search, @@ -313,10 +314,7 @@ def create_file( folder: nil, on_progress: nil ) - api_path = '/storage/buckets/{bucketId}/files' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end @@ -328,6 +326,9 @@ def create_file( raise Appwrite::Exception.new('Missing required parameter: "file"') end + api_path = '/storage/buckets/{bucketId}/files' + .gsub('{bucketId}', bucket_id) + api_params = { fileId: file_id, file: file, @@ -351,6 +352,7 @@ def create_file( param_name: param_name, id_param_name: id_param_name, on_progress: on_progress, + method: 'POST', response_type: Models::File ) end @@ -366,18 +368,18 @@ def get_file( bucket_id:, file_id: ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = {} api_headers = { @@ -409,18 +411,18 @@ def update_file( name: nil, permissions: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { name: name, permissions: permissions, @@ -452,23 +454,24 @@ def delete_file( bucket_id:, file_id: ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -493,18 +496,18 @@ def get_file_download( file_id:, token: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}/download' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}/download' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { token: token, } @@ -532,7 +535,7 @@ def get_file_download( # @param [String] file_id File ID # @param [Integer] width Resize preview image width, Pass an integer between 0 to 4000. # @param [Integer] height Resize preview image height, Pass an integer between 0 to 4000. - # @param [ImageGravity] gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right + # @param [ImageGravity] gravity Image crop gravity. Can be one of auto,center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right # @param [Integer] quality Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. # @param [Integer] border_width Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. # @param [String] border_color Preview image border color. Use a valid HEX color, no # is needed for prefix. @@ -560,18 +563,18 @@ def get_file_preview( output: nil, token: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}/preview' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}/preview' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { width: width, height: height, @@ -614,18 +617,18 @@ def get_file_view( file_id:, token: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}/view' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}/view' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { token: token, } diff --git a/lib/appwrite/services/tables_db.rb b/lib/appwrite/services/tables_db.rb index ef709de8..f0ba0f57 100644 --- a/lib/appwrite/services/tables_db.rb +++ b/lib/appwrite/services/tables_db.rb @@ -60,8 +60,6 @@ def create( replicas: nil, sync_mode: nil ) - api_path = '/tablesdb' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -70,6 +68,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/tablesdb' + api_params = { databaseId: database_id, name: name, @@ -95,8 +95,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -187,13 +187,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/tablesdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -222,13 +222,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/tablesdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -257,18 +257,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/tablesdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -289,13 +290,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/tablesdb/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -324,13 +325,13 @@ def create_operations( def get( database_id: ) - api_path = '/tablesdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -365,13 +366,13 @@ def update( replicas: nil, sync_mode: nil ) - api_path = '/tablesdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -404,18 +405,19 @@ def update( def delete( database_id: ) - api_path = '/tablesdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -444,13 +446,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/tablesdb/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -479,13 +481,13 @@ def create_failover( def list_migrations( database_id: ) - api_path = '/tablesdb/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -516,10 +518,7 @@ def create_migration( specification:, auto_cutover: nil ) - api_path = '/tablesdb/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -527,6 +526,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "specification"') end + api_path = '/tablesdb/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { specification: specification, autoCutover: auto_cutover, @@ -557,18 +559,18 @@ def get_migration( database_id:, migration_id: ) - api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' - .gsub('{databaseId}', database_id) - .gsub('{migrationId}', migration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if migration_id.nil? + if migration_id.nil? || migration_id == '' raise Appwrite::Exception.new('Missing required parameter: "migrationId"') end + api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' + .gsub('{databaseId}', database_id) + .gsub('{migrationId}', migration_id) + api_params = {} api_headers = { @@ -596,18 +598,18 @@ def delete_migration( database_id:, migration_id: ) - api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' - .gsub('{databaseId}', database_id) - .gsub('{migrationId}', migration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if migration_id.nil? + if migration_id.nil? || migration_id == '' raise Appwrite::Exception.new('Missing required parameter: "migrationId"') end + api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' + .gsub('{databaseId}', database_id) + .gsub('{migrationId}', migration_id) + api_params = {} api_headers = { @@ -639,18 +641,18 @@ def create_cutover( database_id:, migration_id: ) - api_path = '/tablesdb/{databaseId}/migrations/{migrationId}/cutovers' - .gsub('{databaseId}', database_id) - .gsub('{migrationId}', migration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if migration_id.nil? + if migration_id.nil? || migration_id == '' raise Appwrite::Exception.new('Missing required parameter: "migrationId"') end + api_path = '/tablesdb/{databaseId}/migrations/{migrationId}/cutovers' + .gsub('{databaseId}', database_id) + .gsub('{migrationId}', migration_id) + api_params = {} api_headers = { @@ -685,13 +687,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/tablesdb/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -721,13 +723,13 @@ def list_operations( def get_replicas( database_id: ) - api_path = '/tablesdb/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -754,13 +756,13 @@ def get_replicas( def get_status( database_id: ) - api_path = '/tablesdb/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -792,13 +794,13 @@ def list_tables( search: nil, total: nil ) - api_path = '/tablesdb/{databaseId}/tables' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/tables' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -831,7 +833,7 @@ def list_tables( # @param [] row_security Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] enabled Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. # @param [Array] columns Array of column definitions to create. Each column should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. - # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). # # @return [Table] def create_table( @@ -844,10 +846,7 @@ def create_table( columns: nil, indexes: nil ) - api_path = '/tablesdb/{databaseId}/tables' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -859,6 +858,9 @@ def create_table( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/tablesdb/{databaseId}/tables' + .gsub('{databaseId}', database_id) + api_params = { tableId: table_id, name: name, @@ -895,18 +897,18 @@ def get_table( database_id:, table_id: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = {} api_headers = { @@ -943,18 +945,18 @@ def update_table( enabled: nil, purge: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { name: name, permissions: permissions, @@ -989,23 +991,24 @@ def delete_table( database_id:, table_id: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1030,18 +1033,18 @@ def list_columns( queries: nil, total: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, total: total, @@ -1085,15 +1088,11 @@ def create_big_int_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1105,6 +1104,10 @@ def create_big_int_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1153,20 +1156,15 @@ def update_big_int_column( max: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1178,6 +1176,11 @@ def update_big_int_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1220,15 +1223,11 @@ def create_boolean_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1240,6 +1239,10 @@ def create_boolean_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1281,20 +1284,15 @@ def update_boolean_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1306,6 +1304,11 @@ def update_boolean_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1345,15 +1348,11 @@ def create_datetime_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1365,6 +1364,10 @@ def create_datetime_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1406,20 +1409,15 @@ def update_datetime_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1431,6 +1429,11 @@ def update_datetime_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1471,15 +1474,11 @@ def create_email_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1491,6 +1490,10 @@ def create_email_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1533,20 +1536,15 @@ def update_email_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1558,6 +1556,11 @@ def update_email_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1600,15 +1603,11 @@ def create_enum_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1624,6 +1623,10 @@ def create_enum_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, elements: elements, @@ -1669,20 +1672,15 @@ def update_enum_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1698,6 +1696,11 @@ def update_enum_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { elements: elements, required: required, @@ -1744,15 +1747,11 @@ def create_float_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1764,6 +1763,10 @@ def create_float_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1812,20 +1815,15 @@ def update_float_column( max: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1837,6 +1835,11 @@ def update_float_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1884,15 +1887,11 @@ def create_integer_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1904,6 +1903,10 @@ def create_integer_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1952,20 +1955,15 @@ def update_integer_column( max: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1977,6 +1975,11 @@ def update_integer_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -2019,15 +2022,11 @@ def create_ip_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2039,6 +2038,10 @@ def create_ip_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2081,20 +2084,15 @@ def update_ip_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2106,6 +2104,11 @@ def update_ip_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2143,15 +2146,11 @@ def create_line_column( required:, default: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2163,6 +2162,10 @@ def create_line_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2203,20 +2206,15 @@ def update_line_column( default: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2224,6 +2222,11 @@ def update_line_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2266,15 +2269,11 @@ def create_longtext_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2286,6 +2285,10 @@ def create_longtext_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2329,20 +2332,15 @@ def update_longtext_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2354,6 +2352,11 @@ def update_longtext_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2396,15 +2399,11 @@ def create_mediumtext_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2416,6 +2415,10 @@ def create_mediumtext_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2459,20 +2462,15 @@ def update_mediumtext_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2484,6 +2482,11 @@ def update_mediumtext_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2521,15 +2524,11 @@ def create_point_column( required:, default: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2541,6 +2540,10 @@ def create_point_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2581,20 +2584,15 @@ def update_point_column( default: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2602,6 +2600,11 @@ def update_point_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2639,15 +2642,11 @@ def create_polygon_column( required:, default: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2659,6 +2658,10 @@ def create_polygon_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2699,20 +2702,15 @@ def update_polygon_column( default: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2720,6 +2718,11 @@ def update_polygon_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2765,15 +2768,11 @@ def create_relationship_column( two_way_key: nil, on_delete: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2785,6 +2784,10 @@ def create_relationship_column( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { relatedTableId: related_table_id, type: type, @@ -2809,41 +2812,92 @@ def create_relationship_column( ) end - # - # @deprecated This API has been deprecated since 1.9.0. Please use `TablesDB.createTextColumn` instead. - # - # Create a string column. + # Update relationship column. [Learn more about relationship + # columns](https://appwrite.io/docs/databases-relationships#relationship-columns). # # # @param [String] database_id Database ID. - # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] table_id Table ID. # @param [String] key Column Key. - # @param [Integer] size Column size for text columns, in number of characters. - # @param [] required Is column required? - # @param [String] default Default value for column when not provided. Cannot be set when column is required. - # @param [] array Is column an array? - # @param [] encrypt Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + # @param [RelationMutate] on_delete Delete constraint. Possible values are: cascade, restrict, setNull. + # @param [String] new_key New Column Key. # - # @return [ColumnString] - def create_string_column( + # @return [ColumnRelationship] + def update_relationship_column( database_id:, table_id:, key:, - size:, - required:, - default: nil, - array: nil, - encrypt: nil + on_delete: nil, + new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string' - .gsub('{databaseId}', database_id) + if database_id.nil? || database_id == '' + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if table_id.nil? || table_id == '' + raise Appwrite::Exception.new('Missing required parameter: "tableId"') + end + + if key.nil? || key == '' + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key}' + .gsub('{databaseId}', database_id) .gsub('{tableId}', table_id) + .gsub('{key}', key) - if database_id.nil? + api_params = { + onDelete: on_delete, + newKey: new_key, + } + + 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::ColumnRelationship + ) + end + + # + # @deprecated This API has been deprecated since 1.9.0. Please use `TablesDB.createTextColumn` instead. + # + # Create a string column. + # + # + # @param [String] database_id Database ID. + # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] key Column Key. + # @param [Integer] size Column size for text columns, in number of characters. + # @param [] required Is column required? + # @param [String] default Default value for column when not provided. Cannot be set when column is required. + # @param [] array Is column an array? + # @param [] encrypt Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + # + # @return [ColumnString] + def create_string_column( + database_id:, + table_id:, + key:, + size:, + required:, + default: nil, + array: nil, + encrypt: nil + ) + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2859,6 +2913,10 @@ def create_string_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, size: size, @@ -2908,20 +2966,15 @@ def update_string_column( size: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2933,6 +2986,11 @@ def update_string_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2976,15 +3034,11 @@ def create_text_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2996,6 +3050,10 @@ def create_text_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -3039,20 +3097,15 @@ def update_text_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3064,6 +3117,11 @@ def update_text_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3104,15 +3162,11 @@ def create_url_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3124,6 +3178,10 @@ def create_url_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -3166,20 +3224,15 @@ def update_url_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3191,6 +3244,11 @@ def update_url_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3235,15 +3293,11 @@ def create_varchar_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3259,6 +3313,10 @@ def create_varchar_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, size: size, @@ -3305,20 +3363,15 @@ def update_varchar_column( size: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3330,6 +3383,11 @@ def update_varchar_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3358,29 +3416,29 @@ def update_varchar_column( # @param [String] table_id Table ID. # @param [String] key Column Key. # - # @return [ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnString] + # @return [ColumnBoolean, ColumnBigint, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnPoint, ColumnLine, ColumnPolygon, ColumnVarchar, ColumnText, ColumnMediumtext, ColumnLongtext, ColumnString] def get_column( database_id:, table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -3424,6 +3482,11 @@ def get_column( return Models::ColumnBoolean.from(map: response) end + if response['type'] == 'bigint' + + return Models::ColumnBigint.from(map: response) + end + if response['type'] == 'integer' return Models::ColumnInteger.from(map: response) @@ -3444,6 +3507,41 @@ def get_column( return Models::ColumnRelationship.from(map: response) end + if response['type'] == 'point' + + return Models::ColumnPoint.from(map: response) + end + + if response['type'] == 'linestring' + + return Models::ColumnLine.from(map: response) + end + + if response['type'] == 'polygon' + + return Models::ColumnPolygon.from(map: response) + end + + if response['type'] == 'varchar' + + return Models::ColumnVarchar.from(map: response) + end + + if response['type'] == 'text' + + return Models::ColumnText.from(map: response) + end + + if response['type'] == 'mediumtext' + + return Models::ColumnMediumtext.from(map: response) + end + + if response['type'] == 'longtext' + + return Models::ColumnLongtext.from(map: response) + end + if response['type'] == 'string' return Models::ColumnString.from(map: response) @@ -3464,77 +3562,24 @@ def delete_column( table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end - api_params = {} - - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), - "content-type": 'application/json', - } - - @client.call( - method: 'DELETE', - path: api_path, - headers: api_headers, - params: api_params, - ) - end - - # Update relationship column. [Learn more about relationship - # columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - # - # - # @param [String] database_id Database ID. - # @param [String] table_id Table ID. - # @param [String] key Column Key. - # @param [RelationMutate] on_delete Delete constraint. Possible values are: cascade, restrict, setNull. - # @param [String] new_key New Column Key. - # - # @return [ColumnRelationship] - def update_relationship_column( - database_id:, - table_id:, - key:, - on_delete: nil, - new_key: nil - ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship' + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' .gsub('{databaseId}', database_id) .gsub('{tableId}', table_id) .gsub('{key}', key) - if database_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "databaseId"') - end - - if table_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "tableId"') - end - - if key.nil? - raise Appwrite::Exception.new('Missing required parameter: "key"') - end - - api_params = { - onDelete: on_delete, - newKey: new_key, - } + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -3543,11 +3588,10 @@ def update_relationship_column( } @client.call( - method: 'PATCH', + method: 'DELETE', path: api_path, headers: api_headers, params: api_params, - response_type: Models::ColumnRelationship ) end @@ -3565,18 +3609,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, total: total, @@ -3598,7 +3642,9 @@ def list_indexes( # Creates an index on the columns listed. Your index should include all the # columns you will query in a single request. - # Type can be `key`, `fulltext`, or `unique`. + # Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` + # is only available on PostgreSQL and lets `contains`, `startsWith`, and + # `endsWith` queries on string columns use an index. # # @param [String] database_id Database ID. # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3618,15 +3664,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3642,6 +3684,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "columns"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, type: type, @@ -3677,23 +3723,23 @@ def get_index( table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -3722,28 +3768,29 @@ def delete_index( table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3773,18 +3820,18 @@ def list_rows( total: nil, ttl: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3827,15 +3874,11 @@ def create_row( permissions: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3847,6 +3890,10 @@ def create_row( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { rowId: row_id, data: data, @@ -3886,15 +3933,11 @@ def create_rows( rows:, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3902,6 +3945,10 @@ def create_rows( raise Appwrite::Exception.new('Missing required parameter: "rows"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { rows: rows, transactionId: transaction_id, @@ -3940,15 +3987,11 @@ def upsert_rows( rows:, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3956,6 +3999,10 @@ def upsert_rows( raise Appwrite::Exception.new('Missing required parameter: "rows"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { rows: rows, transactionId: transaction_id, @@ -3993,18 +4040,18 @@ def update_rows( queries: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { data: data, queries: queries, @@ -4041,18 +4088,18 @@ def delete_rows( queries: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -4090,23 +4137,23 @@ def get_row( queries: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -4147,23 +4194,23 @@ def upsert_row( permissions: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { data: data, permissions: permissions, @@ -4204,23 +4251,23 @@ def update_row( permissions: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { data: data, permissions: permissions, @@ -4256,23 +4303,23 @@ def delete_row( row_id:, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { transactionId: transaction_id, } @@ -4280,6 +4327,7 @@ def delete_row( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -4310,28 +4358,28 @@ def decrement_row_column( min: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - .gsub('{column}', column) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end - if column.nil? + if column.nil? || column == '' raise Appwrite::Exception.new('Missing required parameter: "column"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + .gsub('{column}', column) + api_params = { value: value, min: min, @@ -4373,28 +4421,28 @@ def increment_row_column( max: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - .gsub('{column}', column) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end - if column.nil? + if column.nil? || column == '' raise Appwrite::Exception.new('Missing required parameter: "column"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + .gsub('{column}', column) + api_params = { value: value, max: max, diff --git a/lib/appwrite/services/teams.rb b/lib/appwrite/services/teams.rb index 8e19b572..71a2bc7e 100644 --- a/lib/appwrite/services/teams.rb +++ b/lib/appwrite/services/teams.rb @@ -47,7 +47,7 @@ def list( # # @param [String] team_id Team 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 Team name. Max length: 128 chars. - # @param [Array] roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + # @param [Array] roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long. # # @return [Team] def create( @@ -55,8 +55,6 @@ def create( name:, roles: nil ) - api_path = '/teams' - if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -65,6 +63,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/teams' + api_params = { teamId: team_id, name: name, @@ -94,13 +94,13 @@ def create( def get( team_id: ) - api_path = '/teams/{teamId}' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}' + .gsub('{teamId}', team_id) + api_params = {} api_headers = { @@ -127,10 +127,7 @@ def update_name( team_id:, name: ) - api_path = '/teams/{teamId}' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -138,6 +135,9 @@ def update_name( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/teams/{teamId}' + .gsub('{teamId}', team_id) + api_params = { name: name, } @@ -166,18 +166,19 @@ def update_name( def delete( team_id: ) - api_path = '/teams/{teamId}' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}' + .gsub('{teamId}', team_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -200,13 +201,13 @@ def list_installations( queries: nil, total: nil ) - api_path = '/teams/{teamId}/installations' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}/installations' + .gsub('{teamId}', team_id) + api_params = { queries: queries, total: total, @@ -241,10 +242,7 @@ def create_installation( app_id:, authorization_details: nil ) - api_path = '/teams/{teamId}/installations' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -252,6 +250,9 @@ def create_installation( raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/teams/{teamId}/installations' + .gsub('{teamId}', team_id) + api_params = { appId: app_id, authorizationDetails: authorization_details, @@ -283,18 +284,18 @@ 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? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/teams/{teamId}/installations/{installationId}' + .gsub('{teamId}', team_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -326,18 +327,18 @@ def update_installation( installation_id:, authorization_details: nil ) - api_path = '/teams/{teamId}/installations/{installationId}' - .gsub('{teamId}', team_id) - .gsub('{installationId}', installation_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/teams/{teamId}/installations/{installationId}' + .gsub('{teamId}', team_id) + .gsub('{installationId}', installation_id) + api_params = { authorizationDetails: authorization_details, } @@ -369,18 +370,18 @@ 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? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/teams/{teamId}/installations/{installationId}' + .gsub('{teamId}', team_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -413,13 +414,13 @@ def list_memberships( search: nil, total: nil ) - api_path = '/teams/{teamId}/memberships' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}/memberships' + .gsub('{teamId}', team_id) + api_params = { queries: queries, search: search, @@ -482,10 +483,7 @@ def create_membership( name: nil, membership_id: nil ) - api_path = '/teams/{teamId}/memberships' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -493,6 +491,9 @@ def create_membership( raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/teams/{teamId}/memberships' + .gsub('{teamId}', team_id) + api_params = { email: email, userId: user_id, @@ -530,18 +531,18 @@ def get_membership( team_id:, membership_id: ) - api_path = '/teams/{teamId}/memberships/{membershipId}' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/teams/{teamId}/memberships/{membershipId}' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { @@ -573,15 +574,11 @@ def update_membership( membership_id:, roles: ) - api_path = '/teams/{teamId}/memberships/{membershipId}' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end @@ -589,6 +586,10 @@ def update_membership( raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/teams/{teamId}/memberships/{membershipId}' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = { roles: roles, } @@ -620,23 +621,24 @@ def delete_membership( team_id:, membership_id: ) - api_path = '/teams/{teamId}/memberships/{membershipId}' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/teams/{teamId}/memberships/{membershipId}' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -667,15 +669,11 @@ def update_membership_status( user_id:, secret: ) - api_path = '/teams/{teamId}/memberships/{membershipId}/status' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end @@ -687,6 +685,10 @@ def update_membership_status( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/teams/{teamId}/memberships/{membershipId}/status' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = { userId: user_id, secret: secret, @@ -717,13 +719,13 @@ def update_membership_status( def get_prefs( team_id: ) - api_path = '/teams/{teamId}/prefs' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}/prefs' + .gsub('{teamId}', team_id) + api_params = {} api_headers = { @@ -752,10 +754,7 @@ def update_prefs( team_id:, prefs: ) - api_path = '/teams/{teamId}/prefs' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -763,6 +762,9 @@ def update_prefs( raise Appwrite::Exception.new('Missing required parameter: "prefs"') end + api_path = '/teams/{teamId}/prefs' + .gsub('{teamId}', team_id) + api_params = { prefs: prefs, } diff --git a/lib/appwrite/services/tokens.rb b/lib/appwrite/services/tokens.rb index 72ba9710..0e18e7b5 100644 --- a/lib/appwrite/services/tokens.rb +++ b/lib/appwrite/services/tokens.rb @@ -21,18 +21,18 @@ def list( queries: nil, total: nil ) - api_path = '/tokens/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/tokens/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { queries: queries, total: total, @@ -65,18 +65,18 @@ def create_file_token( file_id:, expire: nil ) - api_path = '/tokens/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/tokens/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { expire: expire, } @@ -104,13 +104,13 @@ def create_file_token( def get( token_id: ) - api_path = '/tokens/{tokenId}' - .gsub('{tokenId}', token_id) - - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/tokens/{tokenId}' + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { @@ -138,13 +138,13 @@ def update( token_id:, expire: nil ) - api_path = '/tokens/{tokenId}' - .gsub('{tokenId}', token_id) - - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/tokens/{tokenId}' + .gsub('{tokenId}', token_id) + api_params = { expire: expire, } @@ -172,18 +172,19 @@ def update( def delete( token_id: ) - api_path = '/tokens/{tokenId}' - .gsub('{tokenId}', token_id) - - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/tokens/{tokenId}' + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/users.rb b/lib/appwrite/services/users.rb index aefa1b2a..dbcf3e56 100644 --- a/lib/appwrite/services/users.rb +++ b/lib/appwrite/services/users.rb @@ -9,7 +9,7 @@ def initialize(client) # Get a list of all the project's users. You can use the query params to # filter your results. # - # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels, impersonator, accessedAt + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, passwordPwned, labels, impersonator, accessedAt # @param [String] search Search term to filter your list results. Max length: 256 chars. # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # @@ -57,12 +57,12 @@ def create( password: nil, name: nil ) - api_path = '/users' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users' + api_params = { userId: user_id, email: email, @@ -103,8 +103,6 @@ def create_argon2_user( password:, name: nil ) - api_path = '/users/argon2' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -117,6 +115,8 @@ def create_argon2_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/argon2' + api_params = { userId: user_id, email: email, @@ -156,8 +156,6 @@ def create_bcrypt_user( password:, name: nil ) - api_path = '/users/bcrypt' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -170,6 +168,8 @@ def create_bcrypt_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/bcrypt' + api_params = { userId: user_id, email: email, @@ -234,18 +234,19 @@ def list_identities( def delete_identity( identity_id: ) - api_path = '/users/identities/{identityId}' - .gsub('{identityId}', identity_id) - - if identity_id.nil? + if identity_id.nil? || identity_id == '' raise Appwrite::Exception.new('Missing required parameter: "identityId"') end + api_path = '/users/identities/{identityId}' + .gsub('{identityId}', identity_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -273,8 +274,6 @@ def create_md5_user( password:, name: nil ) - api_path = '/users/md5' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -287,6 +286,8 @@ def create_md5_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/md5' + api_params = { userId: user_id, email: email, @@ -326,8 +327,6 @@ def create_ph_pass_user( password:, name: nil ) - api_path = '/users/phpass' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -340,6 +339,8 @@ def create_ph_pass_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/phpass' + api_params = { userId: user_id, email: email, @@ -389,8 +390,6 @@ def create_scrypt_user( password_length:, name: nil ) - api_path = '/users/scrypt' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -423,6 +422,8 @@ def create_scrypt_user( raise Appwrite::Exception.new('Missing required parameter: "passwordLength"') end + api_path = '/users/scrypt' + api_params = { userId: user_id, email: email, @@ -474,8 +475,6 @@ def create_scrypt_modified_user( password_signer_key:, name: nil ) - api_path = '/users/scrypt-modified' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -500,6 +499,8 @@ def create_scrypt_modified_user( raise Appwrite::Exception.new('Missing required parameter: "passwordSignerKey"') end + api_path = '/users/scrypt-modified' + api_params = { userId: user_id, email: email, @@ -544,8 +545,6 @@ def create_sha_user( password_version: nil, name: nil ) - api_path = '/users/sha' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -558,6 +557,8 @@ def create_sha_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/sha' + api_params = { userId: user_id, email: email, @@ -589,13 +590,13 @@ def create_sha_user( def get( user_id: ) - api_path = '/users/{userId}' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -625,18 +626,19 @@ def get( def delete( user_id: ) - api_path = '/users/{userId}' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}' + .gsub('{userId}', user_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -657,10 +659,7 @@ def update_email( user_id:, email: ) - api_path = '/users/{userId}/email' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -668,6 +667,9 @@ def update_email( raise Appwrite::Exception.new('Missing required parameter: "email"') end + api_path = '/users/{userId}/email' + .gsub('{userId}', user_id) + api_params = { email: email, } @@ -691,7 +693,10 @@ def update_email( # impersonation headers are used, the request runs as the target user for API # behavior, while internal audit logs still attribute the action to the # original impersonator and store the impersonated target details only in - # internal audit payload data. + # internal audit payload data. Account endpoints are read-only while + # impersonating: they report the target's account, and anything that would + # change it is refused, so an impersonator cannot alter the target's + # credentials or delete their account. # # # @param [String] user_id User ID. @@ -702,10 +707,7 @@ def update_impersonator( user_id:, impersonator: ) - api_path = '/users/{userId}/impersonator' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -713,6 +715,9 @@ def update_impersonator( raise Appwrite::Exception.new('Missing required parameter: "impersonator"') end + api_path = '/users/{userId}/impersonator' + .gsub('{userId}', user_id) + api_params = { impersonator: impersonator, } @@ -746,13 +751,13 @@ def create_jwt( session_id: nil, duration: nil ) - api_path = '/users/{userId}/jwts' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/jwts' + .gsub('{userId}', user_id) + api_params = { sessionId: session_id, duration: duration, @@ -788,10 +793,7 @@ def update_labels( user_id:, labels: ) - api_path = '/users/{userId}/labels' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -799,6 +801,9 @@ def update_labels( raise Appwrite::Exception.new('Missing required parameter: "labels"') end + api_path = '/users/{userId}/labels' + .gsub('{userId}', user_id) + api_params = { labels: labels, } @@ -818,44 +823,6 @@ def update_labels( ) end - # Get the user activity logs list by its unique ID. - # - # @param [String] user_id User 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). Only supported methods are limit and offset - # @param [] total When set to false, the total count returned will be 0 and will not be calculated. - # - # @return [LogList] - def list_logs( - user_id:, - queries: nil, - total: nil - ) - api_path = '/users/{userId}/logs' - .gsub('{userId}', user_id) - - if user_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "userId"') - 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::LogList - ) - end - # Get the user membership list by its unique ID. # # @param [String] user_id User ID. @@ -870,13 +837,13 @@ def list_memberships( search: nil, total: nil ) - api_path = '/users/{userId}/memberships' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/memberships' + .gsub('{userId}', user_id) + api_params = { queries: queries, search: search, @@ -907,10 +874,7 @@ def update_mfa( user_id:, mfa: ) - api_path = '/users/{userId}/mfa' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -918,6 +882,9 @@ def update_mfa( raise Appwrite::Exception.new('Missing required parameter: "mfa"') end + api_path = '/users/{userId}/mfa' + .gsub('{userId}', user_id) + api_params = { mfa: mfa, } @@ -947,11 +914,7 @@ def delete_mfa_authenticator( user_id:, type: ) - api_path = '/users/{userId}/mfa/authenticators/{type}' - .gsub('{userId}', user_id) - .gsub('{type}', type) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -959,11 +922,16 @@ def delete_mfa_authenticator( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/users/{userId}/mfa/authenticators/{type}' + .gsub('{userId}', user_id) + .gsub('{type}', type) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -985,18 +953,18 @@ def get_mfa_challenge( user_id:, challenge_id: ) - api_path = '/users/{userId}/mfa/challenges/{challengeId}' - .gsub('{userId}', user_id) - .gsub('{challengeId}', challenge_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if challenge_id.nil? + if challenge_id.nil? || challenge_id == '' raise Appwrite::Exception.new('Missing required parameter: "challengeId"') end + api_path = '/users/{userId}/mfa/challenges/{challengeId}' + .gsub('{userId}', user_id) + .gsub('{challengeId}', challenge_id) + api_params = {} api_headers = { @@ -1021,13 +989,13 @@ def get_mfa_challenge( def list_mfa_factors( user_id: ) - api_path = '/users/{userId}/mfa/factors' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/factors' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1055,13 +1023,13 @@ def list_mfa_factors( def get_mfa_recovery_codes( user_id: ) - api_path = '/users/{userId}/mfa/recovery-codes' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/recovery-codes' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1089,13 +1057,13 @@ def get_mfa_recovery_codes( def update_mfa_recovery_codes( user_id: ) - api_path = '/users/{userId}/mfa/recovery-codes' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/recovery-codes' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1124,13 +1092,13 @@ def update_mfa_recovery_codes( def create_mfa_recovery_codes( user_id: ) - api_path = '/users/{userId}/mfa/recovery-codes' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/recovery-codes' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1158,10 +1126,7 @@ def update_name( user_id:, name: ) - api_path = '/users/{userId}/name' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1169,6 +1134,9 @@ def update_name( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/users/{userId}/name' + .gsub('{userId}', user_id) + api_params = { name: name, } @@ -1360,10 +1328,7 @@ def update_password( user_id:, password: ) - api_path = '/users/{userId}/password' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1371,6 +1336,9 @@ def update_password( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/{userId}/password' + .gsub('{userId}', user_id) + api_params = { password: password, } @@ -1400,10 +1368,7 @@ def update_phone( user_id:, number: ) - api_path = '/users/{userId}/phone' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1411,6 +1376,9 @@ def update_phone( raise Appwrite::Exception.new('Missing required parameter: "number"') end + api_path = '/users/{userId}/phone' + .gsub('{userId}', user_id) + api_params = { number: number, } @@ -1438,13 +1406,13 @@ def update_phone( def get_prefs( user_id: ) - api_path = '/users/{userId}/prefs' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/prefs' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1473,10 +1441,7 @@ def update_prefs( user_id:, prefs: ) - api_path = '/users/{userId}/prefs' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1484,6 +1449,9 @@ def update_prefs( raise Appwrite::Exception.new('Missing required parameter: "prefs"') end + api_path = '/users/{userId}/prefs' + .gsub('{userId}', user_id) + api_params = { prefs: prefs, } @@ -1513,13 +1481,13 @@ def list_sessions( user_id:, total: nil ) - api_path = '/users/{userId}/sessions' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/sessions' + .gsub('{userId}', user_id) + api_params = { total: total, } @@ -1551,13 +1519,13 @@ def list_sessions( def create_session( user_id: ) - api_path = '/users/{userId}/sessions' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/sessions' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1583,18 +1551,19 @@ def create_session( def delete_sessions( user_id: ) - api_path = '/users/{userId}/sessions' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/sessions' + .gsub('{userId}', user_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1615,23 +1584,24 @@ def delete_session( user_id:, session_id: ) - api_path = '/users/{userId}/sessions/{sessionId}' - .gsub('{userId}', user_id) - .gsub('{sessionId}', session_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/users/{userId}/sessions/{sessionId}' + .gsub('{userId}', user_id) + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1653,10 +1623,7 @@ def update_status( user_id:, status: ) - api_path = '/users/{userId}/status' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1664,6 +1631,9 @@ def update_status( raise Appwrite::Exception.new('Missing required parameter: "status"') end + api_path = '/users/{userId}/status' + .gsub('{userId}', user_id) + api_params = { status: status, } @@ -1695,13 +1665,13 @@ def list_targets( queries: nil, total: nil ) - api_path = '/users/{userId}/targets' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/targets' + .gsub('{userId}', user_id) + api_params = { queries: queries, total: total, @@ -1739,10 +1709,7 @@ def create_target( provider_id: nil, name: nil ) - api_path = '/users/{userId}/targets' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1758,6 +1725,9 @@ def create_target( raise Appwrite::Exception.new('Missing required parameter: "identifier"') end + api_path = '/users/{userId}/targets' + .gsub('{userId}', user_id) + api_params = { targetId: target_id, providerType: provider_type, @@ -1791,18 +1761,18 @@ def get_target( user_id:, target_id: ) - api_path = '/users/{userId}/targets/{targetId}' - .gsub('{userId}', user_id) - .gsub('{targetId}', target_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if target_id.nil? + if target_id.nil? || target_id == '' raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/users/{userId}/targets/{targetId}' + .gsub('{userId}', user_id) + .gsub('{targetId}', target_id) + api_params = {} api_headers = { @@ -1835,18 +1805,18 @@ def update_target( provider_id: nil, name: nil ) - api_path = '/users/{userId}/targets/{targetId}' - .gsub('{userId}', user_id) - .gsub('{targetId}', target_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if target_id.nil? + if target_id.nil? || target_id == '' raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/users/{userId}/targets/{targetId}' + .gsub('{userId}', user_id) + .gsub('{targetId}', target_id) + api_params = { identifier: identifier, providerId: provider_id, @@ -1878,23 +1848,24 @@ def delete_target( user_id:, target_id: ) - api_path = '/users/{userId}/targets/{targetId}' - .gsub('{userId}', user_id) - .gsub('{targetId}', target_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if target_id.nil? + if target_id.nil? || target_id == '' raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/users/{userId}/targets/{targetId}' + .gsub('{userId}', user_id) + .gsub('{targetId}', target_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1921,13 +1892,13 @@ def create_token( length: nil, expire: nil ) - api_path = '/users/{userId}/tokens' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/tokens' + .gsub('{userId}', user_id) + api_params = { length: length, expire: expire, @@ -1958,10 +1929,7 @@ def update_email_verification( user_id:, email_verification: ) - api_path = '/users/{userId}/verification' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1969,6 +1937,9 @@ def update_email_verification( raise Appwrite::Exception.new('Missing required parameter: "emailVerification"') end + api_path = '/users/{userId}/verification' + .gsub('{userId}', user_id) + api_params = { emailVerification: email_verification, } @@ -1998,10 +1969,7 @@ def update_phone_verification( user_id:, phone_verification: ) - api_path = '/users/{userId}/verification/phone' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2009,6 +1977,9 @@ def update_phone_verification( raise Appwrite::Exception.new('Missing required parameter: "phoneVerification"') end + api_path = '/users/{userId}/verification/phone' + .gsub('{userId}', user_id) + api_params = { phoneVerification: phone_verification, } diff --git a/lib/appwrite/services/vectors_db.rb b/lib/appwrite/services/vectors_db.rb index 5d8fe64e..a3440518 100644 --- a/lib/appwrite/services/vectors_db.rb +++ b/lib/appwrite/services/vectors_db.rb @@ -57,8 +57,6 @@ def create( replicas: nil, sync_mode: nil ) - api_path = '/vectorsdb' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -67,6 +65,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/vectorsdb' + api_params = { databaseId: database_id, name: name, @@ -92,8 +92,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -184,13 +184,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/vectorsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/vectorsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -254,18 +254,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/vectorsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -286,13 +287,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/vectorsdb/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -321,13 +322,13 @@ def create_operations( def get( database_id: ) - api_path = '/vectorsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -362,10 +363,7 @@ def update( replicas: nil, sync_mode: nil ) - api_path = '/vectorsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -373,6 +371,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/vectorsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -405,18 +406,19 @@ def update( def delete( database_id: ) - api_path = '/vectorsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -442,13 +444,13 @@ def list_collections( search: nil, total: nil ) - api_path = '/vectorsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -492,10 +494,7 @@ def create_collection( document_security: nil, enabled: nil ) - api_path = '/vectorsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -511,6 +510,9 @@ def create_collection( raise Appwrite::Exception.new('Missing required parameter: "dimension"') end + api_path = '/vectorsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { collectionId: collection_id, name: name, @@ -546,18 +548,18 @@ def get_collection( database_id:, collection_id: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { @@ -594,15 +596,11 @@ def update_collection( document_security: nil, enabled: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -610,6 +608,10 @@ def update_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { name: name, dimension: dimension, @@ -644,23 +646,24 @@ def delete_collection( database_id:, collection_id: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -690,18 +693,18 @@ def list_documents( total: nil, ttl: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -744,15 +747,11 @@ def create_document( permissions: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -764,6 +763,10 @@ def create_document( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documentId: document_id, data: data, @@ -803,15 +806,11 @@ def create_documents( documents:, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -819,6 +818,10 @@ def create_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -857,15 +860,11 @@ def upsert_documents( documents:, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -873,6 +872,10 @@ def upsert_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -911,18 +914,18 @@ def update_documents( queries: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { data: data, queries: queries, @@ -959,18 +962,18 @@ def delete_documents( queries: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1013,18 +1016,18 @@ def create_query( total: nil, ttl: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/query' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/query' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1064,23 +1067,23 @@ def get_document( queries: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1121,23 +1124,23 @@ def upsert_document( permissions: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1178,23 +1181,23 @@ def update_document( permissions: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1230,23 +1233,23 @@ def delete_document( document_id:, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { transactionId: transaction_id, } @@ -1254,6 +1257,7 @@ def delete_document( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1278,18 +1282,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -1331,15 +1335,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1355,6 +1355,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "attributes"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, type: type, @@ -1390,23 +1394,23 @@ def get_index( collection_id:, key: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -1435,28 +1439,29 @@ def delete_index( collection_id:, key: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1485,13 +1490,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/vectorsdb/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1528,13 +1533,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/vectorsdb/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1564,13 +1569,13 @@ def list_operations( def get_replicas( database_id: ) - api_path = '/vectorsdb/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1597,13 +1602,13 @@ def get_replicas( def get_status( database_id: ) - api_path = '/vectorsdb/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/waf.rb b/lib/appwrite/services/waf.rb index 949dd1ee..24a3b0f7 100644 --- a/lib/appwrite/services/waf.rb +++ b/lib/appwrite/services/waf.rb @@ -137,7 +137,7 @@ def update_bypass_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -284,7 +284,7 @@ def update_challenge_rule( difficulty: nil, ttl: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -415,7 +415,7 @@ def update_deny_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -578,7 +578,7 @@ def update_rate_limit_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -728,7 +728,7 @@ def update_redirect_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -771,7 +771,7 @@ def update_redirect_rule( def get_rule( rule_id: ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -833,7 +833,7 @@ def get_rule( def delete_rule( rule_id: ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end diff --git a/lib/appwrite/services/webhooks.rb b/lib/appwrite/services/webhooks.rb index 893cc08e..8f1a17cd 100644 --- a/lib/appwrite/services/webhooks.rb +++ b/lib/appwrite/services/webhooks.rb @@ -47,8 +47,8 @@ def list( # @param [Array] events Events list. Maximum of 100 events are allowed. # @param [] enabled Enable or disable a webhook. # @param [] tls Certificate verification, false for disabled or true for enabled. - # @param [String] auth_username Webhook HTTP user. Max length: 256 chars. - # @param [String] auth_password Webhook HTTP password. Max length: 256 chars. + # @param [String] auth_username Webhook HTTP user. Max length: 255 chars. + # @param [String] auth_password Webhook HTTP password. Max length: 2048 chars. # @param [String] secret Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. # # @return [Webhook] @@ -63,8 +63,6 @@ def create( auth_password: nil, secret: nil ) - api_path = '/webhooks' - if webhook_id.nil? raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end @@ -81,6 +79,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "events"') end + api_path = '/webhooks' + api_params = { webhookId: webhook_id, url: url, @@ -117,13 +117,13 @@ def create( def get( webhook_id: ) - api_path = '/webhooks/{webhookId}' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end + api_path = '/webhooks/{webhookId}' + .gsub('{webhookId}', webhook_id) + api_params = {} api_headers = { @@ -149,8 +149,8 @@ def get( # @param [Array] events Events list. Maximum of 100 events are allowed. # @param [] enabled Enable or disable a webhook. # @param [] tls Certificate verification, false for disabled or true for enabled. - # @param [String] auth_username Webhook HTTP user. Max length: 256 chars. - # @param [String] auth_password Webhook HTTP password. Max length: 256 chars. + # @param [String] auth_username Webhook HTTP user. Max length: 255 chars. + # @param [String] auth_password Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. # # @return [Webhook] def update( @@ -163,10 +163,7 @@ def update( auth_username: nil, auth_password: nil ) - api_path = '/webhooks/{webhookId}' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end @@ -182,6 +179,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "events"') end + api_path = '/webhooks/{webhookId}' + .gsub('{webhookId}', webhook_id) + api_params = { name: name, url: url, @@ -216,18 +216,19 @@ def update( def delete( webhook_id: ) - api_path = '/webhooks/{webhookId}' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end + api_path = '/webhooks/{webhookId}' + .gsub('{webhookId}', webhook_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -250,13 +251,13 @@ def update_secret( webhook_id:, secret: nil ) - api_path = '/webhooks/{webhookId}/secret' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end + api_path = '/webhooks/{webhookId}/secret' + .gsub('{webhookId}', webhook_id) + api_params = { secret: secret, } From 26f99c4ec863c04696e30f14d0c60133eb64858e Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 14 Oct 2026 18:20:47 +0100 Subject: [PATCH 2/4] feat: SDK update for the 2.5.x majors --- CHANGELOG.md | 15 + README.md | 4 +- appwrite.gemspec | 2 +- docs/examples/account/list-logs.md | 17 - docs/examples/avatars/get-screenshot.md | 3 +- docs/examples/databases/create-documents.md | 11 +- docs/examples/databases/create-index.md | 2 +- docs/examples/databases/delete-documents.md | 2 +- docs/examples/databases/upsert-documents.md | 11 +- docs/examples/documentsdb/create-documents.md | 11 +- docs/examples/documentsdb/create-index.md | 2 +- docs/examples/documentsdb/delete-documents.md | 2 +- docs/examples/documentsdb/upsert-documents.md | 11 +- docs/examples/domains/get-price.md | 2 +- docs/examples/domains/list-prices.md | 2 +- .../embeddings/create-text-embeddings.md | 2 +- docs/examples/graphql/mutation.md | 4 +- docs/examples/graphql/query.md | 4 +- .../messaging/create-twilio-provider.md | 2 +- docs/examples/mongo/update.md | 2 +- docs/examples/mysql/update.md | 2 +- docs/examples/oauth2/approve.md | 2 +- docs/examples/oauth2/authorize-post.md | 4 +- docs/examples/oauth2/authorize.md | 4 +- .../oauth2/create-device-authorization.md | 4 +- docs/examples/oauth2/create-grant.md | 2 +- docs/examples/oauth2/create-par.md | 4 +- docs/examples/oauth2/create-token.md | 4 +- docs/examples/oauth2/get-grant.md | 2 +- docs/examples/oauth2/list-organizations.md | 2 +- docs/examples/oauth2/list-projects.md | 2 +- docs/examples/oauth2/reject.md | 2 +- docs/examples/oauth2/revoke.md | 2 +- docs/examples/organization/create-key.md | 20 - docs/examples/organization/delete-key.md | 16 - docs/examples/organization/get-key.md | 16 - docs/examples/organization/list-keys.md | 17 - docs/examples/organization/update-key.md | 20 - docs/examples/postgresql/update.md | 2 +- docs/examples/project/create-ephemeral-key.md | 2 +- docs/examples/project/create-smtp-test.md | 2 +- docs/examples/project/update-key.md | 2 +- docs/examples/project/update-labels.md | 2 +- .../examples/project/update-o-auth-2-kakao.md | 4 +- docs/examples/storage/get-file-preview.md | 2 +- docs/examples/tablesdb/create-index.md | 2 +- docs/examples/tablesdb/create-rows.md | 11 +- docs/examples/tablesdb/delete-rows.md | 2 +- docs/examples/tablesdb/upsert-rows.md | 11 +- docs/examples/teams/create-membership.md | 2 +- docs/examples/teams/update-membership.md | 2 +- docs/examples/users/list-logs.md | 18 - docs/examples/users/update-labels.md | 2 +- docs/examples/vectorsdb/create-collection.md | 2 +- docs/examples/vectorsdb/create-documents.md | 15 +- docs/examples/vectorsdb/create-index.md | 2 +- docs/examples/vectorsdb/create-operations.md | 10 +- docs/examples/vectorsdb/delete-documents.md | 2 +- docs/examples/vectorsdb/update-collection.md | 2 +- docs/examples/vectorsdb/upsert-documents.md | 15 +- docs/examples/webhooks/create.md | 2 +- docs/examples/webhooks/update.md | 2 +- lib/appwrite.rb | 14 +- lib/appwrite/client.rb | 32 +- lib/appwrite/enums/billing_plan_group.rb | 1 - lib/appwrite/enums/organization_key_scopes.rb | 22 - lib/appwrite/models/activity_event.rb | 1 + lib/appwrite/models/activity_event_list.rb | 1 + lib/appwrite/models/additional_resource.rb | 1 + lib/appwrite/models/algo_argon2.rb | 1 + lib/appwrite/models/algo_bcrypt.rb | 1 + lib/appwrite/models/algo_md5.rb | 1 + lib/appwrite/models/algo_phpass.rb | 1 + lib/appwrite/models/algo_scrypt.rb | 1 + lib/appwrite/models/algo_scrypt_modified.rb | 1 + lib/appwrite/models/algo_sha.rb | 1 + lib/appwrite/models/app.rb | 1 + lib/appwrite/models/app_installation.rb | 1 + lib/appwrite/models/app_installation_list.rb | 1 + lib/appwrite/models/app_key.rb | 1 + lib/appwrite/models/app_key_list.rb | 1 + lib/appwrite/models/app_scope.rb | 1 + lib/appwrite/models/app_scope_list.rb | 1 + lib/appwrite/models/app_secret.rb | 1 + lib/appwrite/models/app_secret_list.rb | 1 + lib/appwrite/models/app_secret_plaintext.rb | 1 + lib/appwrite/models/apps_list.rb | 1 + lib/appwrite/models/attribute_bigint.rb | 1 + lib/appwrite/models/attribute_boolean.rb | 1 + lib/appwrite/models/attribute_datetime.rb | 1 + lib/appwrite/models/attribute_email.rb | 1 + lib/appwrite/models/attribute_enum.rb | 1 + lib/appwrite/models/attribute_float.rb | 1 + lib/appwrite/models/attribute_integer.rb | 1 + lib/appwrite/models/attribute_ip.rb | 1 + lib/appwrite/models/attribute_line.rb | 1 + lib/appwrite/models/attribute_list.rb | 1 + lib/appwrite/models/attribute_longtext.rb | 1 + lib/appwrite/models/attribute_mediumtext.rb | 1 + lib/appwrite/models/attribute_object.rb | 1 + lib/appwrite/models/attribute_point.rb | 1 + lib/appwrite/models/attribute_polygon.rb | 1 + lib/appwrite/models/attribute_relationship.rb | 1 + lib/appwrite/models/attribute_string.rb | 1 + lib/appwrite/models/attribute_text.rb | 1 + lib/appwrite/models/attribute_url.rb | 1 + lib/appwrite/models/attribute_varchar.rb | 1 + lib/appwrite/models/attribute_vector.rb | 1 + lib/appwrite/models/backup_archive.rb | 1 + lib/appwrite/models/backup_archive_list.rb | 1 + lib/appwrite/models/backup_policy.rb | 1 + lib/appwrite/models/backup_policy_list.rb | 1 + lib/appwrite/models/backup_restoration.rb | 1 + .../models/backup_restoration_list.rb | 1 + lib/appwrite/models/billing_limits.rb | 16 +- lib/appwrite/models/billing_plan.rb | 20 +- .../models/billing_plan_addon_details.rb | 1 + .../billing_plan_dedicated_database_limits.rb | 38 +- lib/appwrite/models/billing_plan_limits.rb | 4 +- .../models/billing_plan_supported_addons.rb | 1 + lib/appwrite/models/block.rb | 37 +- lib/appwrite/models/bucket.rb | 1 + lib/appwrite/models/bucket_list.rb | 1 + lib/appwrite/models/collection.rb | 1 + lib/appwrite/models/collection_list.rb | 1 + lib/appwrite/models/column_bigint.rb | 1 + lib/appwrite/models/column_boolean.rb | 1 + lib/appwrite/models/column_datetime.rb | 1 + lib/appwrite/models/column_email.rb | 1 + lib/appwrite/models/column_enum.rb | 1 + lib/appwrite/models/column_float.rb | 1 + lib/appwrite/models/column_index.rb | 3 +- lib/appwrite/models/column_index_list.rb | 1 + lib/appwrite/models/column_integer.rb | 1 + lib/appwrite/models/column_ip.rb | 1 + lib/appwrite/models/column_line.rb | 1 + lib/appwrite/models/column_list.rb | 1 + lib/appwrite/models/column_longtext.rb | 1 + lib/appwrite/models/column_mediumtext.rb | 1 + lib/appwrite/models/column_point.rb | 1 + lib/appwrite/models/column_polygon.rb | 1 + lib/appwrite/models/column_relationship.rb | 1 + lib/appwrite/models/column_string.rb | 1 + lib/appwrite/models/column_text.rb | 1 + lib/appwrite/models/column_url.rb | 1 + lib/appwrite/models/column_varchar.rb | 1 + lib/appwrite/models/continent.rb | 1 + lib/appwrite/models/continent_list.rb | 1 + lib/appwrite/models/country.rb | 1 + lib/appwrite/models/country_list.rb | 1 + lib/appwrite/models/currency.rb | 1 + lib/appwrite/models/currency_list.rb | 1 + lib/appwrite/models/database.rb | 1 + lib/appwrite/models/database_list.rb | 1 + lib/appwrite/models/database_migration.rb | 1 + .../models/database_migration_list.rb | 1 + lib/appwrite/models/database_status.rb | 5 +- .../models/database_status_connections.rb | 1 + .../models/database_status_replica.rb | 1 + lib/appwrite/models/database_status_volume.rb | 1 + lib/appwrite/models/dedicated_database.rb | 1 + .../models/dedicated_database_backup.rb | 1 + .../models/dedicated_database_backup_list.rb | 1 + .../dedicated_database_backup_storage.rb | 1 + .../models/dedicated_database_branch.rb | 1 + .../models/dedicated_database_branch_list.rb | 1 + .../models/dedicated_database_execution.rb | 1 + .../dedicated_database_execution_column.rb | 1 + .../models/dedicated_database_extensions.rb | 1 + .../models/dedicated_database_list.rb | 1 + .../models/dedicated_database_member.rb | 1 + .../models/dedicated_database_operation.rb | 1 + .../dedicated_database_operation_list.rb | 1 + .../models/dedicated_database_pitr_windows.rb | 1 + .../models/dedicated_database_pooler.rb | 1 + .../models/dedicated_database_replicas.rb | 1 + .../models/dedicated_database_restoration.rb | 1 + .../dedicated_database_restoration_list.rb | 1 + .../dedicated_database_specification.rb | 1 + .../dedicated_database_specification_list.rb | 12 +- ...edicated_database_specification_pricing.rb | 42 - lib/appwrite/models/deployment.rb | 1 + lib/appwrite/models/deployment_list.rb | 1 + lib/appwrite/models/dev_key.rb | 62 - lib/appwrite/models/document.rb | 1 + lib/appwrite/models/document_list.rb | 1 + lib/appwrite/models/email_template.rb | 1 + lib/appwrite/models/email_template_list.rb | 1 + lib/appwrite/models/embedding.rb | 1 + lib/appwrite/models/embedding_list.rb | 1 + lib/appwrite/models/ephemeral_key.rb | 1 + lib/appwrite/models/execution.rb | 1 + lib/appwrite/models/execution_list.rb | 1 + lib/appwrite/models/file.rb | 1 + lib/appwrite/models/file_list.rb | 1 + lib/appwrite/models/framework.rb | 1 + lib/appwrite/models/framework_adapter.rb | 1 + lib/appwrite/models/framework_list.rb | 1 + lib/appwrite/models/function.rb | 3 +- lib/appwrite/models/function_list.rb | 1 + lib/appwrite/models/headers.rb | 1 + lib/appwrite/models/identity.rb | 1 + lib/appwrite/models/identity_list.rb | 1 + lib/appwrite/models/index.rb | 3 +- lib/appwrite/models/index_list.rb | 1 + lib/appwrite/models/insight.rb | 1 + lib/appwrite/models/insight_cta.rb | 1 + lib/appwrite/models/insight_list.rb | 1 + lib/appwrite/models/jwt.rb | 1 + lib/appwrite/models/key.rb | 1 + lib/appwrite/models/key_list.rb | 1 + lib/appwrite/models/language.rb | 1 + lib/appwrite/models/language_list.rb | 1 + lib/appwrite/models/locale.rb | 1 + lib/appwrite/models/locale_code.rb | 1 + lib/appwrite/models/locale_code_list.rb | 1 + lib/appwrite/models/log.rb | 132 -- lib/appwrite/models/log_list.rb | 32 - lib/appwrite/models/membership.rb | 1 + lib/appwrite/models/membership_list.rb | 1 + lib/appwrite/models/message.rb | 1 + lib/appwrite/models/message_list.rb | 1 + lib/appwrite/models/mfa_challenge.rb | 1 + lib/appwrite/models/mfa_challenge_secret.rb | 1 + lib/appwrite/models/mfa_factors.rb | 1 + lib/appwrite/models/mfa_recovery_codes.rb | 1 + lib/appwrite/models/mfa_type.rb | 1 + lib/appwrite/models/mock_number.rb | 1 + lib/appwrite/models/mock_number_list.rb | 1 + lib/appwrite/models/o_auth2_amazon.rb | 1 + lib/appwrite/models/o_auth2_apple.rb | 1 + lib/appwrite/models/o_auth2_appwrite.rb | 1 + lib/appwrite/models/o_auth2_auth0.rb | 3 +- lib/appwrite/models/o_auth2_authentik.rb | 1 + lib/appwrite/models/o_auth2_autodesk.rb | 1 + lib/appwrite/models/o_auth2_bitbucket.rb | 1 + lib/appwrite/models/o_auth2_bitly.rb | 1 + lib/appwrite/models/o_auth2_box.rb | 1 + lib/appwrite/models/o_auth2_cloudflare.rb | 1 + lib/appwrite/models/o_auth2_dailymotion.rb | 1 + lib/appwrite/models/o_auth2_discord.rb | 3 +- lib/appwrite/models/o_auth2_disqus.rb | 1 + lib/appwrite/models/o_auth2_dropbox.rb | 1 + lib/appwrite/models/o_auth2_etsy.rb | 1 + lib/appwrite/models/o_auth2_facebook.rb | 1 + lib/appwrite/models/o_auth2_figma.rb | 1 + lib/appwrite/models/o_auth2_fusion_auth.rb | 1 + lib/appwrite/models/o_auth2_github.rb | 3 +- lib/appwrite/models/o_auth2_gitlab.rb | 1 + lib/appwrite/models/o_auth2_google.rb | 1 + lib/appwrite/models/o_auth2_hugging_face.rb | 1 + lib/appwrite/models/o_auth2_keycloak.rb | 1 + lib/appwrite/models/o_auth2_kick.rb | 1 + lib/appwrite/models/o_auth2_linkedin.rb | 1 + lib/appwrite/models/o_auth2_microsoft.rb | 3 +- lib/appwrite/models/o_auth2_notion.rb | 1 + lib/appwrite/models/o_auth2_oidc.rb | 11 +- lib/appwrite/models/o_auth2_okta.rb | 3 +- lib/appwrite/models/o_auth2_paypal.rb | 1 + lib/appwrite/models/o_auth2_podio.rb | 1 + lib/appwrite/models/o_auth2_provider_list.rb | 1 + lib/appwrite/models/o_auth2_resend.rb | 1 + lib/appwrite/models/o_auth2_salesforce.rb | 3 +- lib/appwrite/models/o_auth2_slack.rb | 1 + lib/appwrite/models/o_auth2_spotify.rb | 1 + lib/appwrite/models/o_auth2_stripe.rb | 1 + lib/appwrite/models/o_auth2_tradeshift.rb | 1 + lib/appwrite/models/o_auth2_twitch.rb | 1 + lib/appwrite/models/o_auth2_word_press.rb | 1 + lib/appwrite/models/o_auth2_x.rb | 1 + lib/appwrite/models/o_auth2_yahoo.rb | 1 + lib/appwrite/models/o_auth2_yandex.rb | 1 + lib/appwrite/models/o_auth2_zoho.rb | 3 +- lib/appwrite/models/o_auth2_zoom.rb | 1 + lib/appwrite/models/oauth2_approve.rb | 1 + lib/appwrite/models/oauth2_authorize.rb | 1 + lib/appwrite/models/oauth2_consent.rb | 1 + lib/appwrite/models/oauth2_consent_list.rb | 1 + lib/appwrite/models/oauth2_consent_token.rb | 1 + .../models/oauth2_consent_token_list.rb | 1 + .../models/oauth2_device_authorization.rb | 1 + lib/appwrite/models/oauth2_grant.rb | 1 + lib/appwrite/models/oauth2_organization.rb | 1 + .../models/oauth2_organization_list.rb | 1 + lib/appwrite/models/oauth2_par.rb | 1 + lib/appwrite/models/oauth2_project.rb | 1 + lib/appwrite/models/oauth2_project_list.rb | 1 + lib/appwrite/models/oauth2_reject.rb | 1 + lib/appwrite/models/oauth2_token.rb | 1 + lib/appwrite/models/organization.rb | 1 + lib/appwrite/models/passkey.rb | 1 + lib/appwrite/models/passkey_challenge.rb | 1 + lib/appwrite/models/passkey_list.rb | 1 + lib/appwrite/models/phone.rb | 1 + lib/appwrite/models/phone_list.rb | 1 + lib/appwrite/models/platform_android.rb | 1 + lib/appwrite/models/platform_apple.rb | 1 + lib/appwrite/models/platform_linux.rb | 1 + lib/appwrite/models/platform_list.rb | 1 + lib/appwrite/models/platform_web.rb | 1 + lib/appwrite/models/platform_windows.rb | 1 + .../models/policy_deny_aliased_email.rb | 1 + .../models/policy_deny_corporate_email.rb | 1 + .../models/policy_deny_disposable_email.rb | 1 + lib/appwrite/models/policy_deny_free_email.rb | 1 + lib/appwrite/models/policy_list.rb | 1 + .../models/policy_membership_privacy.rb | 1 + lib/appwrite/models/policy_mfa_factors.rb | 1 + lib/appwrite/models/policy_passkey.rb | 1 + .../models/policy_password_dictionary.rb | 1 + .../models/policy_password_history.rb | 1 + .../models/policy_password_personal_data.rb | 1 + .../models/policy_password_strength.rb | 1 + lib/appwrite/models/policy_session_alert.rb | 1 + .../models/policy_session_duration.rb | 1 + .../models/policy_session_invalidation.rb | 1 + lib/appwrite/models/policy_session_limit.rb | 1 + lib/appwrite/models/policy_user_limit.rb | 1 + lib/appwrite/models/postgres_extension.rb | 1 + lib/appwrite/models/presence.rb | 1 + lib/appwrite/models/presence_list.rb | 1 + lib/appwrite/models/program.rb | 1 + lib/appwrite/models/project.rb | 30 +- lib/appwrite/models/project_auth_method.rb | 1 + lib/appwrite/models/project_list.rb | 1 + lib/appwrite/models/project_protocol.rb | 1 + lib/appwrite/models/project_service.rb | 1 + lib/appwrite/models/provider.rb | 3 +- lib/appwrite/models/provider_list.rb | 1 + lib/appwrite/models/proxy_invalidation.rb | 1 + lib/appwrite/models/proxy_rule.rb | 1 + lib/appwrite/models/proxy_rule_list.rb | 1 + lib/appwrite/models/report.rb | 1 + lib/appwrite/models/report_list.rb | 1 + lib/appwrite/models/resource_token.rb | 1 + lib/appwrite/models/resource_token_list.rb | 1 + lib/appwrite/models/row.rb | 1 + lib/appwrite/models/row_list.rb | 1 + lib/appwrite/models/runtime.rb | 1 + lib/appwrite/models/runtime_list.rb | 1 + lib/appwrite/models/session.rb | 1 + lib/appwrite/models/session_list.rb | 1 + lib/appwrite/models/site.rb | 1 + lib/appwrite/models/site_list.rb | 1 + lib/appwrite/models/specification.rb | 1 + lib/appwrite/models/specification_list.rb | 1 + lib/appwrite/models/subscriber.rb | 1 + lib/appwrite/models/subscriber_list.rb | 1 + lib/appwrite/models/table.rb | 1 + lib/appwrite/models/table_list.rb | 1 + lib/appwrite/models/target.rb | 1 + lib/appwrite/models/target_list.rb | 1 + lib/appwrite/models/team.rb | 1 + lib/appwrite/models/team_list.rb | 1 + lib/appwrite/models/token.rb | 1 + lib/appwrite/models/token_secret.rb | 1 + lib/appwrite/models/topic.rb | 1 + lib/appwrite/models/topic_list.rb | 1 + lib/appwrite/models/transaction.rb | 1 + lib/appwrite/models/transaction_list.rb | 1 + lib/appwrite/models/usage_billing_plan.rb | 32 +- lib/appwrite/models/user.rb | 1 + lib/appwrite/models/user_list.rb | 1 + lib/appwrite/models/variable.rb | 1 + lib/appwrite/models/variable_list.rb | 1 + lib/appwrite/models/vectorsdb_collection.rb | 1 + .../models/vectorsdb_collection_list.rb | 1 + lib/appwrite/models/webhook.rb | 1 + lib/appwrite/models/webhook_list.rb | 1 + lib/appwrite/services/account.rb | 244 ++-- lib/appwrite/services/activities.rb | 8 +- lib/appwrite/services/advisor.rb | 37 +- lib/appwrite/services/apps.rb | 178 +-- lib/appwrite/services/avatars.rb | 42 +- lib/appwrite/services/backups.rb | 60 +- lib/appwrite/services/databases.rb | 946 +++++++------- lib/appwrite/services/documents_db.rb | 385 +++--- lib/appwrite/services/domains.rb | 110 +- lib/appwrite/services/embeddings.rb | 4 +- lib/appwrite/services/functions.rb | 221 ++-- lib/appwrite/services/graphql.rb | 8 +- lib/appwrite/services/messaging.rb | 308 ++--- lib/appwrite/services/mongo.rb | 262 ++-- lib/appwrite/services/mysql.rb | 286 ++-- lib/appwrite/services/oauth2.rb | 54 +- lib/appwrite/services/organization.rb | 301 +---- lib/appwrite/services/postgresql.rb | 314 ++--- lib/appwrite/services/presences.rb | 33 +- lib/appwrite/services/project.rb | 291 +++-- lib/appwrite/services/proxy.rb | 47 +- lib/appwrite/services/sites.rb | 212 +-- lib/appwrite/services/storage.rb | 121 +- lib/appwrite/services/tables_db.rb | 1152 +++++++++-------- lib/appwrite/services/teams.rb | 164 +-- lib/appwrite/services/tokens.rb | 49 +- lib/appwrite/services/users.rb | 369 +++--- lib/appwrite/services/vectors_db.rb | 357 ++--- lib/appwrite/services/waf.rb | 14 +- lib/appwrite/services/webhooks.rb | 45 +- lib/appwrite/topic.rb | 102 ++ 400 files changed, 3935 insertions(+), 3996 deletions(-) delete mode 100644 docs/examples/account/list-logs.md delete mode 100644 docs/examples/organization/create-key.md delete mode 100644 docs/examples/organization/delete-key.md delete mode 100644 docs/examples/organization/get-key.md delete mode 100644 docs/examples/organization/list-keys.md delete mode 100644 docs/examples/organization/update-key.md delete mode 100644 docs/examples/users/list-logs.md delete mode 100644 lib/appwrite/enums/organization_key_scopes.rb delete mode 100644 lib/appwrite/models/dedicated_database_specification_pricing.rb delete mode 100644 lib/appwrite/models/dev_key.rb delete mode 100644 lib/appwrite/models/log.rb delete mode 100644 lib/appwrite/models/log_list.rb create mode 100644 lib/appwrite/topic.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index cdc8ff1a..d6a71976 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Change Log +## 29.0.0 + +* Breaking: requests send `X-Appwrite-Response-Format: 2.5.0`; responses follow the 2.5 shapes +* Breaking: removed `account.list_logs`, `users.list_logs` and the `Log`/`LogList` models +* Breaking: removed `organization.create_key`, `list_keys`, `update_key` and `OrganizationKeyScopes`; use project keys +* Breaking: removed `Client#set_dev_key`, the `DevKey` model and `Project#dev_keys` +* Breaking: removed `BillingPlanGroup::STARTER` +* Breaking: removed `DedicatedDatabaseSpecificationPricing` and `DedicatedDatabaseSpecificationList#pricing` +* Breaking: removed `Block` fields `reason`, `project_name`, `region`, `organization_name`, `organization_id` and `billing_plan` +* Breaking: OAuth2 `resource:` params now take an array +* Breaking: `BackupRestoration#options` is now a hash +* Breaking: some response fields became optional, such as `BillingPlan#usage` and `DedicatedDatabase#engine` +* Added: `Topic` helper to build MQTT topics for push messages +* Updated: missing response fields fall back to their documented defaults in more models + ## 28.4.0 * Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones diff --git a/README.md b/README.md index ebd62348..108c7722 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Ruby SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.0.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 1.9.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-ruby/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-ruby/releases) when APIs differ. Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Ruby SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/appwrite.gemspec b/appwrite.gemspec index 7fe70b3b..4054abff 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '28.4.0' + spec.version = '29.0.0' spec.license = 'BSD-3-Clause' spec.summary = 'Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API' spec.author = 'Appwrite Team' diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md deleted file mode 100644 index 171d4306..00000000 --- a/docs/examples/account/list-logs.md +++ /dev/null @@ -1,17 +0,0 @@ -```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_logs( - queries: [], # optional - total: false # optional -) -``` diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 742c87fd..331e4292 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -14,8 +14,7 @@ avatars = Avatars.new(client) result = avatars.get_screenshot( url: 'https://example.com', headers: { - "Authorization" => "Bearer token123", - "X-Custom-Header" => "value" + "Accept-Language" => "en-US,en;q=0.9" }, # optional viewport_width: 1920, # optional viewport_height: 1080, # optional diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 60acd19f..25b4cbd9 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -13,7 +13,16 @@ databases = Databases.new(client) result = databases.create_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index e3e9238a..924f512f 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -16,7 +16,7 @@ result = databases.create_index( collection_id: '', key: '', type: DatabasesIndexType::KEY, - attributes: [], + attributes: ["username"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index c9309bd9..29ea3583 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -13,7 +13,7 @@ databases = Databases.new(client) result = databases.delete_documents( database_id: '', collection_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 49432e01..6cf394c5 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -13,7 +13,16 @@ databases = Databases.new(client) result = databases.upsert_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index 1277f4ac..b895f1c5 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -13,7 +13,16 @@ documents_db = DocumentsDB.new(client) result = documents_db.create_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md index d1891f9a..a8c4e35f 100644 --- a/docs/examples/documentsdb/create-index.md +++ b/docs/examples/documentsdb/create-index.md @@ -16,7 +16,7 @@ result = documents_db.create_index( collection_id: '', key: '', type: DocumentsDBIndexType::KEY, - attributes: [], + attributes: ["username"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md index cd628c75..b1ea2032 100644 --- a/docs/examples/documentsdb/delete-documents.md +++ b/docs/examples/documentsdb/delete-documents.md @@ -13,7 +13,7 @@ documents_db = DocumentsDB.new(client) result = documents_db.delete_documents( database_id: '', collection_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md index f7f05970..0876756c 100644 --- a/docs/examples/documentsdb/upsert-documents.md +++ b/docs/examples/documentsdb/upsert-documents.md @@ -13,7 +13,16 @@ documents_db = DocumentsDB.new(client) result = documents_db.upsert_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/domains/get-price.md b/docs/examples/domains/get-price.md index 4658fab8..7727397c 100644 --- a/docs/examples/domains/get-price.md +++ b/docs/examples/domains/get-price.md @@ -13,7 +13,7 @@ domains = Domains.new(client) result = domains.get_price( domain: 'example.com', - period_years: nil, # optional + period_years: null, # optional registration_type: DomainRegistrationType::NEW # optional ) ``` diff --git a/docs/examples/domains/list-prices.md b/docs/examples/domains/list-prices.md index a99450dc..14ced00c 100644 --- a/docs/examples/domains/list-prices.md +++ b/docs/examples/domains/list-prices.md @@ -13,7 +13,7 @@ domains = Domains.new(client) result = domains.list_prices( domains: [], - period_years: nil, # optional + period_years: null, # optional registration_type: DomainRegistrationType::NEW # optional ) ``` diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index facbe573..fecbe281 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -12,7 +12,7 @@ client = Client.new embeddings = Embeddings.new(client) result = embeddings.create_text_embeddings( - texts: [], + texts: ["Appwrite helps developers build applications.", "Find documents with semantic search."], model: EmbeddingModel::NOMIC_EMBED_TEXT # optional ) ``` diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index a71a8bd6..3493178e 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -11,6 +11,8 @@ client = Client.new graphql = Graphql.new(client) result = graphql.mutation( - query: {} + query: { + "query" => "mutation { accountUpdateName(name: "Walter") { name } }" + } ) ``` diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 49561b15..2432fd81 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -11,6 +11,8 @@ client = Client.new graphql = Graphql.new(client) result = graphql.query( - query: {} + query: { + "query" => "query { localeGet { ip } }" + } ) ``` diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index fa86a835..a68eec6f 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -13,7 +13,7 @@ messaging = Messaging.new(client) result = messaging.create_twilio_provider( provider_id: '', name: '', - from: '+12065550100', # optional + from: '', # optional account_sid: '', # optional auth_token: '', # optional enabled: false # optional diff --git a/docs/examples/mongo/update.md b/docs/examples/mongo/update.md index 792e1e0d..55f02acd 100644 --- a/docs/examples/mongo/update.md +++ b/docs/examples/mongo/update.md @@ -25,7 +25,7 @@ result = mongo.update( storage_autoscaling: false, # optional storage_autoscaling_threshold_percent: 50, # optional storage_autoscaling_max_gb: 0, # optional - metrics_trace_sample_rate: nil, # optional + metrics_trace_sample_rate: null, # optional metrics_slow_query_log_threshold_ms: 0, # optional sql_api_enabled: false, # optional sql_api_allowed_statements: [], # optional diff --git a/docs/examples/mysql/update.md b/docs/examples/mysql/update.md index 0d972eab..2ba792ea 100644 --- a/docs/examples/mysql/update.md +++ b/docs/examples/mysql/update.md @@ -25,7 +25,7 @@ result = mysql.update( storage_autoscaling: false, # optional storage_autoscaling_threshold_percent: 50, # optional storage_autoscaling_max_gb: 0, # optional - metrics_trace_sample_rate: nil, # optional + metrics_trace_sample_rate: null, # optional metrics_slow_query_log_threshold_ms: 0, # optional sql_api_enabled: false, # optional sql_api_allowed_statements: [], # optional diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md index 6576dbec..99818b87 100644 --- a/docs/examples/oauth2/approve.md +++ b/docs/examples/oauth2/approve.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 75f092a2..d4f058ce 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -22,7 +22,7 @@ result = oauth2.authorize_post( prompt: '', # optional max_age: 0, # optional authorization_details: '', # optional - resource: '', # optional + resource: [], # optional audience: '', # optional request_uri: '' # optional ) diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index d7d5befc..474e4e96 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -22,7 +22,7 @@ result = oauth2.authorize( prompt: '', # optional max_age: 0, # optional authorization_details: '', # optional - resource: '', # 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 index 102671db..3fde848d 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -14,7 +14,7 @@ result = oauth2.create_device_authorization( client_id: '', # optional scope: '', # optional authorization_details: '', # optional - resource: '', # optional + resource: [], # optional audience: '' # optional ) ``` diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md index 9184cbf7..f4bff9f2 100644 --- a/docs/examples/oauth2/create-grant.md +++ b/docs/examples/oauth2/create-grant.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index 192e5ff1..2ac703ea 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -22,7 +22,7 @@ result = oauth2.create_par( prompt: '', # optional max_age: 0, # optional authorization_details: '', # optional - resource: '', # optional + resource: [], # optional audience: '' # optional ) ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index 6e0cabc1..8b0a9c52 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -19,7 +19,7 @@ result = oauth2.create_token( client_secret: '', # optional code_verifier: '', # optional redirect_uri: 'https://example.com', # optional - resource: '', # optional + resource: [], # optional audience: '' # optional ) ``` diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md index e6b80763..81985286 100644 --- a/docs/examples/oauth2/get-grant.md +++ b/docs/examples/oauth2/get-grant.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md index 28b026e4..2e9ed664 100644 --- a/docs/examples/oauth2/list-organizations.md +++ b/docs/examples/oauth2/list-organizations.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md index 3f8c64f2..f7a69362 100644 --- a/docs/examples/oauth2/list-projects.md +++ b/docs/examples/oauth2/list-projects.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md index bf00d990..e10fd752 100644 --- a/docs/examples/oauth2/reject.md +++ b/docs/examples/oauth2/reject.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md index 6b709451..36c5c145 100644 --- a/docs/examples/oauth2/revoke.md +++ b/docs/examples/oauth2/revoke.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/organization/create-key.md b/docs/examples/organization/create-key.md deleted file mode 100644 index 3d920ccc..00000000 --- a/docs/examples/organization/create-key.md +++ /dev/null @@ -1,20 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite -include Appwrite::Enums - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -organization = Organization.new(client) - -result = organization.create_key( - key_id: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTS_READ], - expire: '2020-10-15T06:38:00.000+00:00' # optional -) -``` diff --git a/docs/examples/organization/delete-key.md b/docs/examples/organization/delete-key.md deleted file mode 100644 index 0e490c3b..00000000 --- a/docs/examples/organization/delete-key.md +++ /dev/null @@ -1,16 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -organization = Organization.new(client) - -result = organization.delete_key( - key_id: '' -) -``` diff --git a/docs/examples/organization/get-key.md b/docs/examples/organization/get-key.md deleted file mode 100644 index 28899bb6..00000000 --- a/docs/examples/organization/get-key.md +++ /dev/null @@ -1,16 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -organization = Organization.new(client) - -result = organization.get_key( - key_id: '' -) -``` diff --git a/docs/examples/organization/list-keys.md b/docs/examples/organization/list-keys.md deleted file mode 100644 index d54a2642..00000000 --- a/docs/examples/organization/list-keys.md +++ /dev/null @@ -1,17 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -organization = Organization.new(client) - -result = organization.list_keys( - queries: [], # optional - total: false # optional -) -``` diff --git a/docs/examples/organization/update-key.md b/docs/examples/organization/update-key.md deleted file mode 100644 index c7542126..00000000 --- a/docs/examples/organization/update-key.md +++ /dev/null @@ -1,20 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite -include Appwrite::Enums - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -organization = Organization.new(client) - -result = organization.update_key( - key_id: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTS_READ], - expire: '2020-10-15T06:38:00.000+00:00' # optional -) -``` diff --git a/docs/examples/postgresql/update.md b/docs/examples/postgresql/update.md index 48d76044..f43a9e88 100644 --- a/docs/examples/postgresql/update.md +++ b/docs/examples/postgresql/update.md @@ -25,7 +25,7 @@ result = postgresql.update( storage_autoscaling: false, # optional storage_autoscaling_threshold_percent: 50, # optional storage_autoscaling_max_gb: 0, # optional - metrics_trace_sample_rate: nil, # optional + metrics_trace_sample_rate: null, # optional metrics_slow_query_log_threshold_ms: 0, # optional sql_api_enabled: false, # optional sql_api_allowed_statements: [], # optional diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index 6f0d9b66..d7928fa5 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -12,7 +12,7 @@ client = Client.new project = Project.new(client) result = project.create_ephemeral_key( - scopes: [ProjectKeyScopes::PROJECT_READ], + scopes: [ProjectKeyScopes::USERS_READ], duration: 600 ) ``` diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index 1e1d1eae..34853638 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -11,6 +11,6 @@ client = Client.new project = Project.new(client) result = project.create_smtp_test( - emails: [] + emails: ["recipient@example.com"] ) ``` diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index b192315d..992775bb 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -14,7 +14,7 @@ project = Project.new(client) result = project.update_key( key_id: '', name: '', - scopes: [ProjectKeyScopes::PROJECT_READ], + scopes: [ProjectKeyScopes::USERS_READ], expire: '2020-10-15T06:38:00.000+00:00' # optional ) ``` diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index f57cec70..a01667b9 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -11,6 +11,6 @@ client = Client.new project = Project.new(client) result = project.update_labels( - labels: [] + labels: ["production"] ) ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index 035810f7..5acde9f9 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -14,7 +14,7 @@ project = Project.new(client) result = project.update_o_auth2_kakao( client_id: '', # optional client_secret: '', # optional - prompt: [ProjectOAuth2KakaoPrompt::NONE], # optional - enabled: false # optional + enabled: false, # optional + prompt: [ProjectOAuth2KakaoPrompt::NONE] # optional ) ``` diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index 3b4ce03d..d40c3a5e 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -16,7 +16,7 @@ result = storage.get_file_preview( file_id: '', width: 0, # optional height: 0, # optional - gravity: ImageGravity::CENTER, # optional + gravity: ImageGravity::AUTO, # optional quality: -1, # optional border_width: 0, # optional border_color: 'FFFFFF', # optional diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index a0453818..d1e2dba7 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -16,7 +16,7 @@ result = tables_db.create_index( table_id: '', key: '', type: TablesDBIndexType::KEY, - columns: [], + columns: ["username"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index 2fc8a2b1..9ff8dd78 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -13,7 +13,16 @@ tables_db = TablesDB.new(client) result = tables_db.create_rows( database_id: '', table_id: '', - rows: [], + rows: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 69ab29e8..41d6acdb 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -13,7 +13,7 @@ tables_db = TablesDB.new(client) result = tables_db.delete_rows( database_id: '', table_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index d450971f..9d5cce80 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -13,7 +13,16 @@ tables_db = TablesDB.new(client) result = tables_db.upsert_rows( database_id: '', table_id: '', - rows: [], + rows: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index c90a80d6..9016bb71 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -12,7 +12,7 @@ teams = Teams.new(client) result = teams.create_membership( team_id: '', - roles: [], + roles: ["editor"], email: 'email@example.com', # optional user_id: '', # optional phone: '+12065550100', # optional diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index f94e3879..898f7eae 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -13,6 +13,6 @@ teams = Teams.new(client) result = teams.update_membership( team_id: '', membership_id: '', - roles: [] + roles: ["editor"] ) ``` diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md deleted file mode 100644 index dd9809e3..00000000 --- a/docs/examples/users/list-logs.md +++ /dev/null @@ -1,18 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -users = Users.new(client) - -result = users.list_logs( - user_id: '', - queries: [], # optional - total: false # optional -) -``` diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 0110cb9e..bdad6d04 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -12,6 +12,6 @@ users = Users.new(client) result = users.update_labels( user_id: '', - labels: [] + labels: ["subscriber"] ) ``` diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md index b449f541..4b16940b 100644 --- a/docs/examples/vectorsdb/create-collection.md +++ b/docs/examples/vectorsdb/create-collection.md @@ -16,7 +16,7 @@ result = vectors_db.create_collection( database_id: '', collection_id: '', name: '', - dimension: 1, + dimension: 4, permissions: [Permission.read(Role.any())], # optional document_security: false, # optional enabled: false # optional diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index 9f3a4d4d..3a89c1ee 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -13,7 +13,20 @@ vectors_db = VectorsDB.new(client) result = vectors_db.create_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md index d7880ab2..60d2624a 100644 --- a/docs/examples/vectorsdb/create-index.md +++ b/docs/examples/vectorsdb/create-index.md @@ -16,7 +16,7 @@ result = vectors_db.create_index( collection_id: '', key: '', type: VectorsDBIndexType::HNSW_EUCLIDEAN, - attributes: [], + attributes: ["embeddings"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md index 6817930b..23e14d1c 100644 --- a/docs/examples/vectorsdb/create-operations.md +++ b/docs/examples/vectorsdb/create-operations.md @@ -19,7 +19,15 @@ result = vectors_db.create_operations( "collectionId": "", "documentId": "", "data": { - "name": "Walter O'Brien" + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } } } ] # optional diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md index bb1173a3..a050c8c3 100644 --- a/docs/examples/vectorsdb/delete-documents.md +++ b/docs/examples/vectorsdb/delete-documents.md @@ -13,7 +13,7 @@ vectors_db = VectorsDB.new(client) result = vectors_db.delete_documents( database_id: '', collection_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md index 0dfdac13..eee8c975 100644 --- a/docs/examples/vectorsdb/update-collection.md +++ b/docs/examples/vectorsdb/update-collection.md @@ -16,7 +16,7 @@ result = vectors_db.update_collection( database_id: '', collection_id: '', name: '', - dimension: 1, # optional + dimension: 4, # optional permissions: [Permission.read(Role.any())], # optional document_security: false, # optional enabled: false # optional diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md index d737f107..e1fea6cc 100644 --- a/docs/examples/vectorsdb/upsert-documents.md +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -13,7 +13,20 @@ vectors_db = VectorsDB.new(client) result = vectors_db.upsert_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index 9f231f7b..6d754424 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -14,7 +14,7 @@ result = webhooks.create( webhook_id: '', url: 'https://example.com/webhook', name: '', - events: [], + events: ["users.*.create"], enabled: false, # optional tls: false, # optional auth_username: '', # optional diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index ad3fa894..859d15f2 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -14,7 +14,7 @@ result = webhooks.update( webhook_id: '', name: '', url: 'https://example.com/webhook', - events: [], + events: ["users.*.create"], enabled: false, # optional tls: false, # optional auth_username: '', # optional diff --git a/lib/appwrite.rb b/lib/appwrite.rb index 7cf6053d..229741d6 100644 --- a/lib/appwrite.rb +++ b/lib/appwrite.rb @@ -11,6 +11,7 @@ require_relative 'appwrite/permission' require_relative 'appwrite/role' require_relative 'appwrite/id' +require_relative 'appwrite/topic' require_relative 'appwrite/operator' require_relative 'appwrite/models/row_list' @@ -24,7 +25,6 @@ require_relative 'appwrite/models/user_list' require_relative 'appwrite/models/session_list' require_relative 'appwrite/models/identity_list' -require_relative 'appwrite/models/log_list' require_relative 'appwrite/models/file_list' require_relative 'appwrite/models/bucket_list' require_relative 'appwrite/models/resource_token_list' @@ -111,7 +111,6 @@ require_relative 'appwrite/models/row' require_relative 'appwrite/models/document' require_relative 'appwrite/models/presence' -require_relative 'appwrite/models/log' require_relative 'appwrite/models/user' require_relative 'appwrite/models/algo_md5' require_relative 'appwrite/models/algo_sha' @@ -147,7 +146,6 @@ require_relative 'appwrite/models/webhook' require_relative 'appwrite/models/key' require_relative 'appwrite/models/ephemeral_key' -require_relative 'appwrite/models/dev_key' require_relative 'appwrite/models/mock_number' require_relative 'appwrite/models/o_auth2_github' require_relative 'appwrite/models/o_auth2_discord' @@ -211,6 +209,10 @@ require_relative 'appwrite/models/policy_membership_privacy' require_relative 'appwrite/models/policy_mfa_factors' require_relative 'appwrite/models/policy_passkey' +require_relative 'appwrite/models/policy_deny_aliased_email' +require_relative 'appwrite/models/policy_deny_disposable_email' +require_relative 'appwrite/models/policy_deny_free_email' +require_relative 'appwrite/models/policy_deny_corporate_email' require_relative 'appwrite/models/platform_web' require_relative 'appwrite/models/platform_apple' require_relative 'appwrite/models/platform_android' @@ -280,10 +282,6 @@ require_relative 'appwrite/models/organization' require_relative 'appwrite/models/dedicated_database_pitr_windows' require_relative 'appwrite/models/backup_policy' -require_relative 'appwrite/models/policy_deny_aliased_email' -require_relative 'appwrite/models/policy_deny_disposable_email' -require_relative 'appwrite/models/policy_deny_free_email' -require_relative 'appwrite/models/policy_deny_corporate_email' require_relative 'appwrite/models/dedicated_database_pooler' require_relative 'appwrite/models/postgres_extension' require_relative 'appwrite/models/program' @@ -291,7 +289,6 @@ require_relative 'appwrite/models/dedicated_database_restoration_list' 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' @@ -366,7 +363,6 @@ require_relative 'appwrite/enums/execution_method' require_relative 'appwrite/enums/message_priority' require_relative 'appwrite/enums/smtp_encryption' -require_relative 'appwrite/enums/organization_key_scopes' require_relative 'appwrite/enums/region' require_relative 'appwrite/enums/project_auth_method_id' require_relative 'appwrite/enums/project_o_auth2_auth0_prompt' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index 99f8f563..caae8247 100644 --- a/lib/appwrite/client.rb +++ b/lib/appwrite/client.rb @@ -14,8 +14,8 @@ def initialize 'x-sdk-name' => 'Ruby', 'x-sdk-platform' => 'server', 'x-sdk-language' => 'ruby', - 'x-sdk-version' => '28.4.0', - 'X-Appwrite-Response-Format' => '2.0.0' + 'x-sdk-version' => '29.0.0', + 'X-Appwrite-Response-Format' => '2.5.0' } @endpoint = 'https://cloud.appwrite.io/v1' @config = {} @@ -130,20 +130,6 @@ def set_forwarded_user_agent(value) self end - # Set DevKey - # - # Your secret dev API key - # - # @param [String] value The value to set for the DevKey header - # - # @return [self] - def set_dev_key(value) - add_header('x-appwrite-dev-key', value) - @config['devkey'] = value - - self - end - # Set Cookie # # The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @@ -283,6 +269,16 @@ def chunked_upload( ) input_file = params[param_name.to_sym] + if input_file.nil? + return call( + method: method, + path: path, + headers: headers, + params: params, + response_type: response_type, + ) + end + case input_file.source_type when 'path' size = ::File.size(input_file.path) @@ -290,7 +286,7 @@ def chunked_upload( size = input_file.data.bytesize end - if size < @chunk_size + if size <= @chunk_size || response_type == "text" if input_file.source_type == 'path' input_file.data = IO.read(input_file.path) end @@ -546,6 +542,8 @@ def decode_text(response) def encode_form_data(value, key = nil) case value when Hash + return encode_form_data(value.to_json, key) unless key.nil? + value.map { |k, v| encode_form_data(v, k) }.join when Array value.map { |v| encode_form_data(v, "#{key}[]") }.join diff --git a/lib/appwrite/enums/billing_plan_group.rb b/lib/appwrite/enums/billing_plan_group.rb index 1f3ca3cf..59fde6e6 100644 --- a/lib/appwrite/enums/billing_plan_group.rb +++ b/lib/appwrite/enums/billing_plan_group.rb @@ -1,7 +1,6 @@ module Appwrite module Enums module BillingPlanGroup - STARTER = 'starter' FREE = 'free' START = 'start' PRO = 'pro' diff --git a/lib/appwrite/enums/organization_key_scopes.rb b/lib/appwrite/enums/organization_key_scopes.rb deleted file mode 100644 index 9a8c7aa3..00000000 --- a/lib/appwrite/enums/organization_key_scopes.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Appwrite - module Enums - module OrganizationKeyScopes - PROJECTS_READ = 'projects.read' - PROJECTS_WRITE = 'projects.write' - DEVKEYS_READ = 'devKeys.read' - 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' - ORGANIZATION_WRITE = 'organization.write' - DOMAINS_READ = 'domains.read' - DOMAINS_WRITE = 'domains.write' - KEYS_READ = 'keys.read' - KEYS_WRITE = 'keys.write' - end - end -end diff --git a/lib/appwrite/models/activity_event.rb b/lib/appwrite/models/activity_event.rb index 34699a2b..ed92c606 100644 --- a/lib/appwrite/models/activity_event.rb +++ b/lib/appwrite/models/activity_event.rb @@ -96,6 +96,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "actorType" => "", "actorId" => "", "actorEmail" => "", "actorName" => "", "resourceParent" => "", "resourceType" => "", "resourceId" => "", "resource" => "", "event" => "", "userAgent" => "", "ip" => "", "mode" => "", "country" => "", "continentCode" => "", "city" => "", "subdivisions" => "", "isp" => "", "autonomousSystemNumber" => "", "autonomousSystemOrganization" => "", "connectionType" => "", "connectionUsageType" => "", "connectionOrganization" => "", "time" => "", "projectId" => "", "teamId" => "", "hostname" => "", "sdk" => "", "sdkVersion" => "" }.merge(map) ActivityEvent.new( id: map["$id"], actor_type: map["actorType"], diff --git a/lib/appwrite/models/activity_event_list.rb b/lib/appwrite/models/activity_event_list.rb index 6c8ebfe3..214f21cd 100644 --- a/lib/appwrite/models/activity_event_list.rb +++ b/lib/appwrite/models/activity_event_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "events" => [] }.merge(map) ActivityEventList.new( total: map["total"], events: map["events"].map { |it| ActivityEvent.from(map: it) } diff --git a/lib/appwrite/models/additional_resource.rb b/lib/appwrite/models/additional_resource.rb index 54d3ad41..fea38e38 100644 --- a/lib/appwrite/models/additional_resource.rb +++ b/lib/appwrite/models/additional_resource.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "unit" => "", "currency" => "", "price" => 0, "value" => 0, "invoiceDesc" => "" }.merge(map) AdditionalResource.new( name: map["name"], unit: map["unit"], diff --git a/lib/appwrite/models/algo_argon2.rb b/lib/appwrite/models/algo_argon2.rb index d2413e72..213dc487 100644 --- a/lib/appwrite/models/algo_argon2.rb +++ b/lib/appwrite/models/algo_argon2.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "type" => "argon2", "memoryCost" => 0, "timeCost" => 0, "threads" => 0 }.merge(map) AlgoArgon2.new( type: map["type"], memory_cost: map["memoryCost"], diff --git a/lib/appwrite/models/algo_bcrypt.rb b/lib/appwrite/models/algo_bcrypt.rb index 0407c819..13c7758c 100644 --- a/lib/appwrite/models/algo_bcrypt.rb +++ b/lib/appwrite/models/algo_bcrypt.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "bcrypt" }.merge(map) AlgoBcrypt.new( type: map["type"] ) diff --git a/lib/appwrite/models/algo_md5.rb b/lib/appwrite/models/algo_md5.rb index d7f315c9..0a79ce23 100644 --- a/lib/appwrite/models/algo_md5.rb +++ b/lib/appwrite/models/algo_md5.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "md5" }.merge(map) AlgoMd5.new( type: map["type"] ) diff --git a/lib/appwrite/models/algo_phpass.rb b/lib/appwrite/models/algo_phpass.rb index 496d2065..2a44c3b6 100644 --- a/lib/appwrite/models/algo_phpass.rb +++ b/lib/appwrite/models/algo_phpass.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "phpass" }.merge(map) AlgoPhpass.new( type: map["type"] ) diff --git a/lib/appwrite/models/algo_scrypt.rb b/lib/appwrite/models/algo_scrypt.rb index 7128bb2f..8cf555c8 100644 --- a/lib/appwrite/models/algo_scrypt.rb +++ b/lib/appwrite/models/algo_scrypt.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "type" => "scrypt", "costCpu" => 8, "costMemory" => 14, "costParallel" => 1, "length" => 64 }.merge(map) AlgoScrypt.new( type: map["type"], cost_cpu: map["costCpu"], diff --git a/lib/appwrite/models/algo_scrypt_modified.rb b/lib/appwrite/models/algo_scrypt_modified.rb index 8862154c..3a27d34d 100644 --- a/lib/appwrite/models/algo_scrypt_modified.rb +++ b/lib/appwrite/models/algo_scrypt_modified.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "type" => "scryptMod", "salt" => "", "saltSeparator" => "", "signerKey" => "" }.merge(map) AlgoScryptModified.new( type: map["type"], salt: map["salt"], diff --git a/lib/appwrite/models/algo_sha.rb b/lib/appwrite/models/algo_sha.rb index bd227d57..16dc3be8 100644 --- a/lib/appwrite/models/algo_sha.rb +++ b/lib/appwrite/models/algo_sha.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "sha" }.merge(map) AlgoSha.new( type: map["type"] ) diff --git a/lib/appwrite/models/app.rb b/lib/appwrite/models/app.rb index 5123fbd9..13af49c0 100644 --- a/lib/appwrite/models/app.rb +++ b/lib/appwrite/models/app.rb @@ -87,6 +87,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "description" => "", "clientUri" => "", "logoUri" => "", "privacyPolicyUrl" => "", "termsUrl" => "", "contacts" => [], "tagline" => "", "tags" => [], "labels" => [], "images" => [], "supportUrl" => "", "dataDeletionUrl" => "", "redirectUris" => [], "postLogoutRedirectUris" => [], "enabled" => true, "type" => "confidential", "deviceFlow" => false, "teamId" => "", "userId" => "", "installationScopes" => [], "installationRedirectUrl" => "", "secrets" => [] }.merge(map) App.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_installation.rb b/lib/appwrite/models/app_installation.rb index 32a12a3e..f5b42e6a 100644 --- a/lib/appwrite/models/app_installation.rb +++ b/lib/appwrite/models/app_installation.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "teamId" => "", "scopes" => [], "authorizationDetails" => [], "createdById" => "", "createdByName" => "" }.merge(map) AppInstallation.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_installation_list.rb b/lib/appwrite/models/app_installation_list.rb index d59981cc..0efb5504 100644 --- a/lib/appwrite/models/app_installation_list.rb +++ b/lib/appwrite/models/app_installation_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "installations" => [] }.merge(map) AppInstallationList.new( total: map["total"], installations: map["installations"].map { |it| AppInstallation.from(map: it) } diff --git a/lib/appwrite/models/app_key.rb b/lib/appwrite/models/app_key.rb index f1a457f8..ad9d93c0 100644 --- a/lib/appwrite/models/app_key.rb +++ b/lib/appwrite/models/app_key.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "secret" => "", "hint" => "", "createdById" => "", "createdByName" => "" }.merge(map) AppKey.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_key_list.rb b/lib/appwrite/models/app_key_list.rb index 3ec9ecd7..7d2af88f 100644 --- a/lib/appwrite/models/app_key_list.rb +++ b/lib/appwrite/models/app_key_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "keys" => [] }.merge(map) AppKeyList.new( total: map["total"], keys: map["keys"].map { |it| AppKey.from(map: it) } diff --git a/lib/appwrite/models/app_scope.rb b/lib/appwrite/models/app_scope.rb index c12c0ccc..bd068e37 100644 --- a/lib/appwrite/models/app_scope.rb +++ b/lib/appwrite/models/app_scope.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "value" => "", "description" => "", "type" => "", "category" => "", "deprecated" => false }.merge(map) AppScope.new( value: map["value"], description: map["description"], diff --git a/lib/appwrite/models/app_scope_list.rb b/lib/appwrite/models/app_scope_list.rb index 8a7b772b..82426a7c 100644 --- a/lib/appwrite/models/app_scope_list.rb +++ b/lib/appwrite/models/app_scope_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "scopes" => [] }.merge(map) AppScopeList.new( total: map["total"], scopes: map["scopes"].map { |it| AppScope.from(map: it) } diff --git a/lib/appwrite/models/app_secret.rb b/lib/appwrite/models/app_secret.rb index 4170d66c..f65846a8 100644 --- a/lib/appwrite/models/app_secret.rb +++ b/lib/appwrite/models/app_secret.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "secret" => "", "hint" => "", "createdById" => "", "createdByName" => "" }.merge(map) AppSecret.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_secret_list.rb b/lib/appwrite/models/app_secret_list.rb index d4da1d58..0f1b1a5b 100644 --- a/lib/appwrite/models/app_secret_list.rb +++ b/lib/appwrite/models/app_secret_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "secrets" => [] }.merge(map) AppSecretList.new( total: map["total"], secrets: map["secrets"].map { |it| AppSecret.from(map: it) } diff --git a/lib/appwrite/models/app_secret_plaintext.rb b/lib/appwrite/models/app_secret_plaintext.rb index d36c260a..de5ea6ec 100644 --- a/lib/appwrite/models/app_secret_plaintext.rb +++ b/lib/appwrite/models/app_secret_plaintext.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "secret" => "", "hint" => "", "createdById" => "", "createdByName" => "" }.merge(map) AppSecretPlaintext.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/apps_list.rb b/lib/appwrite/models/apps_list.rb index 354957bc..cff5c27a 100644 --- a/lib/appwrite/models/apps_list.rb +++ b/lib/appwrite/models/apps_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "apps" => [] }.merge(map) AppsList.new( total: map["total"], apps: map["apps"].map { |it| App.from(map: it) } diff --git a/lib/appwrite/models/attribute_bigint.rb b/lib/appwrite/models/attribute_bigint.rb index b2286d7a..3de6d81a 100644 --- a/lib/appwrite/models/attribute_bigint.rb +++ b/lib/appwrite/models/attribute_bigint.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeBigint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_boolean.rb b/lib/appwrite/models/attribute_boolean.rb index 145da450..3f594d2c 100644 --- a/lib/appwrite/models/attribute_boolean.rb +++ b/lib/appwrite/models/attribute_boolean.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeBoolean.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_datetime.rb b/lib/appwrite/models/attribute_datetime.rb index 2cd2387e..7d19713e 100644 --- a/lib/appwrite/models/attribute_datetime.rb +++ b/lib/appwrite/models/attribute_datetime.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeDatetime.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_email.rb b/lib/appwrite/models/attribute_email.rb index d3dc9589..808e07ce 100644 --- a/lib/appwrite/models/attribute_email.rb +++ b/lib/appwrite/models/attribute_email.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "email" }.merge(map) AttributeEmail.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_enum.rb b/lib/appwrite/models/attribute_enum.rb index 758db16d..5eadaece 100644 --- a/lib/appwrite/models/attribute_enum.rb +++ b/lib/appwrite/models/attribute_enum.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "elements" => [], "format" => "enum" }.merge(map) AttributeEnum.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_float.rb b/lib/appwrite/models/attribute_float.rb index fd4c2581..85fad7b5 100644 --- a/lib/appwrite/models/attribute_float.rb +++ b/lib/appwrite/models/attribute_float.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeFloat.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_integer.rb b/lib/appwrite/models/attribute_integer.rb index 0707b347..aeebffff 100644 --- a/lib/appwrite/models/attribute_integer.rb +++ b/lib/appwrite/models/attribute_integer.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeInteger.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_ip.rb b/lib/appwrite/models/attribute_ip.rb index 4ac5e3b2..09f75337 100644 --- a/lib/appwrite/models/attribute_ip.rb +++ b/lib/appwrite/models/attribute_ip.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "ip" }.merge(map) AttributeIp.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_line.rb b/lib/appwrite/models/attribute_line.rb index 23cda309..ca22747e 100644 --- a/lib/appwrite/models/attribute_line.rb +++ b/lib/appwrite/models/attribute_line.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeLine.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_list.rb b/lib/appwrite/models/attribute_list.rb index 4aafafbc..dad98609 100644 --- a/lib/appwrite/models/attribute_list.rb +++ b/lib/appwrite/models/attribute_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "attributes" => [] }.merge(map) AttributeList.new( total: map["total"], attributes: map["attributes"] diff --git a/lib/appwrite/models/attribute_longtext.rb b/lib/appwrite/models/attribute_longtext.rb index 55922b0a..40400db9 100644 --- a/lib/appwrite/models/attribute_longtext.rb +++ b/lib/appwrite/models/attribute_longtext.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeLongtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_mediumtext.rb b/lib/appwrite/models/attribute_mediumtext.rb index 0dea9331..cc8c0cd3 100644 --- a/lib/appwrite/models/attribute_mediumtext.rb +++ b/lib/appwrite/models/attribute_mediumtext.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeMediumtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_object.rb b/lib/appwrite/models/attribute_object.rb index ab85153d..01396202 100644 --- a/lib/appwrite/models/attribute_object.rb +++ b/lib/appwrite/models/attribute_object.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeObject.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_point.rb b/lib/appwrite/models/attribute_point.rb index b236cb17..f1dd0517 100644 --- a/lib/appwrite/models/attribute_point.rb +++ b/lib/appwrite/models/attribute_point.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributePoint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_polygon.rb b/lib/appwrite/models/attribute_polygon.rb index 44ce447a..b5298101 100644 --- a/lib/appwrite/models/attribute_polygon.rb +++ b/lib/appwrite/models/attribute_polygon.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributePolygon.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_relationship.rb b/lib/appwrite/models/attribute_relationship.rb index 9b8da81c..fe8b276c 100644 --- a/lib/appwrite/models/attribute_relationship.rb +++ b/lib/appwrite/models/attribute_relationship.rb @@ -51,6 +51,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "relationType" => "", "twoWay" => false, "twoWayKey" => "", "onDelete" => "restrict", "side" => "" }.merge(map) AttributeRelationship.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_string.rb b/lib/appwrite/models/attribute_string.rb index e5e27203..2f3499ca 100644 --- a/lib/appwrite/models/attribute_string.rb +++ b/lib/appwrite/models/attribute_string.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) AttributeString.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_text.rb b/lib/appwrite/models/attribute_text.rb index 3997ad15..9047c342 100644 --- a/lib/appwrite/models/attribute_text.rb +++ b/lib/appwrite/models/attribute_text.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeText.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_url.rb b/lib/appwrite/models/attribute_url.rb index 2353dc79..e6d62685 100644 --- a/lib/appwrite/models/attribute_url.rb +++ b/lib/appwrite/models/attribute_url.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "url" }.merge(map) AttributeUrl.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_varchar.rb b/lib/appwrite/models/attribute_varchar.rb index 3720b0e0..fe438fea 100644 --- a/lib/appwrite/models/attribute_varchar.rb +++ b/lib/appwrite/models/attribute_varchar.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) AttributeVarchar.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_vector.rb b/lib/appwrite/models/attribute_vector.rb index 3954eefd..8ea3f9d0 100644 --- a/lib/appwrite/models/attribute_vector.rb +++ b/lib/appwrite/models/attribute_vector.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) AttributeVector.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/backup_archive.rb b/lib/appwrite/models/backup_archive.rb index 71ea159d..20852c2d 100644 --- a/lib/appwrite/models/backup_archive.rb +++ b/lib/appwrite/models/backup_archive.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "policyId" => "", "status" => "", "migrationId" => "", "services" => [], "resources" => [] }.merge(map) BackupArchive.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/backup_archive_list.rb b/lib/appwrite/models/backup_archive_list.rb index 9c0cc7cc..848d268c 100644 --- a/lib/appwrite/models/backup_archive_list.rb +++ b/lib/appwrite/models/backup_archive_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "archives" => [] }.merge(map) BackupArchiveList.new( total: map["total"], archives: map["archives"].map { |it| BackupArchive.from(map: it) } diff --git a/lib/appwrite/models/backup_policy.rb b/lib/appwrite/models/backup_policy.rb index 6e8e0376..acd93e45 100644 --- a/lib/appwrite/models/backup_policy.rb +++ b/lib/appwrite/models/backup_policy.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "name" => "", "$createdAt" => "", "$updatedAt" => "", "services" => [], "resources" => [], "retention" => 1, "schedule" => "0 * * * *", "type" => "full", "enabled" => false }.merge(map) BackupPolicy.new( id: map["$id"], name: map["name"], diff --git a/lib/appwrite/models/backup_policy_list.rb b/lib/appwrite/models/backup_policy_list.rb index d5de4a5d..294aa8ca 100644 --- a/lib/appwrite/models/backup_policy_list.rb +++ b/lib/appwrite/models/backup_policy_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "policies" => [] }.merge(map) BackupPolicyList.new( total: map["total"], policies: map["policies"].map { |it| BackupPolicy.from(map: it) } diff --git a/lib/appwrite/models/backup_restoration.rb b/lib/appwrite/models/backup_restoration.rb index 61eb62f4..99ac22c0 100644 --- a/lib/appwrite/models/backup_restoration.rb +++ b/lib/appwrite/models/backup_restoration.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "archiveId" => "", "policyId" => "", "status" => "", "migrationId" => "", "services" => [], "resources" => [], "options" => {} }.merge(map) BackupRestoration.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/backup_restoration_list.rb b/lib/appwrite/models/backup_restoration_list.rb index 671e135b..8f6fb521 100644 --- a/lib/appwrite/models/backup_restoration_list.rb +++ b/lib/appwrite/models/backup_restoration_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "restorations" => [] }.merge(map) BackupRestorationList.new( total: map["total"], restorations: map["restorations"].map { |it| BackupRestoration.from(map: it) } diff --git a/lib/appwrite/models/billing_limits.rb b/lib/appwrite/models/billing_limits.rb index ef61643b..8eefd941 100644 --- a/lib/appwrite/models/billing_limits.rb +++ b/lib/appwrite/models/billing_limits.rb @@ -13,14 +13,14 @@ class BillingLimits attr_reader :budget_limit def initialize( - bandwidth:, - storage:, - users:, - executions:, - gb_hours:, - image_transformations:, - auth_phone:, - budget_limit: + bandwidth: 0, + storage: 0, + users: 0, + executions: 0, + gb_hours: 0, + image_transformations: 0, + auth_phone: 0, + budget_limit: 0 ) @bandwidth = bandwidth @storage = storage diff --git a/lib/appwrite/models/billing_plan.rb b/lib/appwrite/models/billing_plan.rb index 2a5b6644..80c8a90a 100644 --- a/lib/appwrite/models/billing_plan.rb +++ b/lib/appwrite/models/billing_plan.rb @@ -90,7 +90,7 @@ def initialize( storage:, image_transformations:, screenshots_generated:, - members:, + members: 0, webhooks:, waf_rules:, environments:, @@ -115,10 +115,10 @@ def initialize( topics:, auth_phone:, domains:, - activity_logs:, + activity_logs: 1, usage_logs:, - usage_logs_intervals:, - usage_aggregate_only_metrics:, + usage_logs_intervals: ["15m", "1h", "1d"], + usage_aggregate_only_metrics: [], project_inactivity_days:, alert_limit:, usage:, @@ -128,7 +128,7 @@ def initialize( email_branding:, requires_payment_method:, requires_billing_address:, - eligible_countries:, + eligible_countries: [], is_available:, self_service:, premium_support:, @@ -142,10 +142,10 @@ def initialize( supports_free_email_validation:, supports_corporate_email_validation:, supports_project_specific_roles:, - backups_enabled:, + backups_enabled: true, usage_per_project:, supported_addons:, - backup_policies:, + backup_policies: 0, deployment_size:, build_size:, functions_interval_minimum:, @@ -234,6 +234,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "name" => "", "desc" => "", "order" => 0, "price" => 0, "trial" => 0, "bandwidth" => 0, "storage" => 0, "imageTransformations" => 0, "screenshotsGenerated" => 0, "webhooks" => 0, "wafRules" => 0, "environments" => 0, "projects" => 0, "platforms" => 0, "users" => 0, "teams" => 0, "databases" => 0, "databasesReads" => 0, "databasesWrites" => 0, "databasesBatchSize" => 0, "buckets" => 0, "fileSize" => 0, "functions" => 0, "sites" => 0, "executions" => 0, "executionsRetentionCount" => 1000, "GBHours" => 0, "realtime" => 0, "realtimeMessages" => 0, "messages" => 0, "topics" => 0, "authPhone" => 0, "domains" => 0, "usageLogs" => 0, "projectInactivityDays" => 0, "alertLimit" => 80, "budgetCapEnabled" => false, "customSmtp" => false, "emailBranding" => false, "requiresPaymentMethod" => true, "requiresBillingAddress" => false, "isAvailable" => true, "selfService" => true, "premiumSupport" => true, "budgeting" => true, "supportsMockNumbers" => true, "supportsOrganizationRoles" => true, "supportsCredits" => false, "supportsDedicatedDatabases" => false, "supportsDisposableEmailValidation" => false, "supportsCanonicalEmailValidation" => false, "supportsFreeEmailValidation" => false, "supportsCorporateEmailValidation" => false, "supportsProjectSpecificRoles" => false, "usagePerProject" => true, "deploymentSize" => 0, "buildSize" => 0, "functionsIntervalMinimum" => 0, "databasesAllowEncrypt" => false, "databaseComputeCredit" => 0 }.merge(map) BillingPlan.new( id: map["$id"], name: map["name"], @@ -276,7 +277,7 @@ def self.from(map:) usage_aggregate_only_metrics: map["usageAggregateOnlyMetrics"], project_inactivity_days: map["projectInactivityDays"], alert_limit: map["alertLimit"], - usage: UsageBillingPlan.from(map: map["usage"]), + usage: map["usage"].nil? ? nil : UsageBillingPlan.from(map: map["usage"]), addons: BillingPlanAddon.from(map: map["addons"]), budget_cap_enabled: map["budgetCapEnabled"], custom_smtp: map["customSmtp"], @@ -356,7 +357,7 @@ def to_map "usageAggregateOnlyMetrics": @usage_aggregate_only_metrics, "projectInactivityDays": @project_inactivity_days, "alertLimit": @alert_limit, - "usage": @usage.to_map, + "usage": @usage&.to_map, "addons": @addons.to_map, "budgetCapEnabled": @budget_cap_enabled, "customSmtp": @custom_smtp, @@ -397,7 +398,6 @@ def to_map def validate_group(group) valid_group = [ - Appwrite::Enums::BillingPlanGroup::STARTER, Appwrite::Enums::BillingPlanGroup::FREE, Appwrite::Enums::BillingPlanGroup::START, Appwrite::Enums::BillingPlanGroup::PRO, diff --git a/lib/appwrite/models/billing_plan_addon_details.rb b/lib/appwrite/models/billing_plan_addon_details.rb index 3dc5e285..106badcc 100644 --- a/lib/appwrite/models/billing_plan_addon_details.rb +++ b/lib/appwrite/models/billing_plan_addon_details.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "supported" => false, "planIncluded" => 0, "limit" => 0, "type" => "numeric", "price" => 0, "value" => 0, "invoiceDesc" => "" }.merge(map) BillingPlanAddonDetails.new( supported: map["supported"], plan_included: map["planIncluded"], diff --git a/lib/appwrite/models/billing_plan_dedicated_database_limits.rb b/lib/appwrite/models/billing_plan_dedicated_database_limits.rb index 3e179ad2..a6c6bb7c 100644 --- a/lib/appwrite/models/billing_plan_dedicated_database_limits.rb +++ b/lib/appwrite/models/billing_plan_dedicated_database_limits.rb @@ -24,25 +24,25 @@ class BillingPlanDedicatedDatabaseLimits attr_reader :allowed_sync_modes def initialize( - min_cpu:, - max_cpu:, - min_memory_mb:, - max_memory_mb:, - min_storage_gb:, - max_storage_gb:, - max_replicas:, - max_connections:, - max_ip_allowlist_size:, - max_extensions:, - max_backup_retention_days:, - max_pitr_retention_days:, - max_sql_api_max_rows:, - max_sql_api_max_bytes:, - max_sql_api_timeout_seconds:, - max_sql_api_allowed_statements:, - allowed_sql_statements:, - allowed_storage_classes:, - allowed_sync_modes: + min_cpu: 0, + max_cpu: 0, + min_memory_mb: 0, + max_memory_mb: 0, + min_storage_gb: 0, + max_storage_gb: 0, + max_replicas: 0, + max_connections: 0, + max_ip_allowlist_size: 0, + max_extensions: 0, + max_backup_retention_days: 0, + max_pitr_retention_days: 0, + max_sql_api_max_rows: 0, + max_sql_api_max_bytes: 0, + max_sql_api_timeout_seconds: 0, + max_sql_api_allowed_statements: 0, + allowed_sql_statements: [], + allowed_storage_classes: [], + allowed_sync_modes: [] ) @min_cpu = min_cpu @max_cpu = max_cpu diff --git a/lib/appwrite/models/billing_plan_limits.rb b/lib/appwrite/models/billing_plan_limits.rb index 999a55bf..89f5235c 100644 --- a/lib/appwrite/models/billing_plan_limits.rb +++ b/lib/appwrite/models/billing_plan_limits.rb @@ -7,8 +7,8 @@ class BillingPlanLimits attr_reader :daily_credits def initialize( - credits:, - daily_credits: + credits: 0, + daily_credits: 0 ) @credits = credits @daily_credits = daily_credits diff --git a/lib/appwrite/models/billing_plan_supported_addons.rb b/lib/appwrite/models/billing_plan_supported_addons.rb index ea2d8078..430878ac 100644 --- a/lib/appwrite/models/billing_plan_supported_addons.rb +++ b/lib/appwrite/models/billing_plan_supported_addons.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "baa" => false, "premiumGeoDB" => false, "premiumGeoDBOrg" => false }.merge(map) BillingPlanSupportedAddons.new( baa: map["baa"], premium_geo_db: map["premiumGeoDB"], diff --git a/lib/appwrite/models/block.rb b/lib/appwrite/models/block.rb index 4a1c81a6..d022ac08 100644 --- a/lib/appwrite/models/block.rb +++ b/lib/appwrite/models/block.rb @@ -7,53 +7,30 @@ class Block attr_reader :resource_type attr_reader :resource_id attr_reader :mode - attr_reader :reason attr_reader :expired_at - attr_reader :project_name - attr_reader :region - attr_reader :organization_name - attr_reader :organization_id - attr_reader :billing_plan def initialize( created_at:, resource_type:, resource_id:, mode:, - reason:, - expired_at:, - project_name:, - region:, - organization_name:, - organization_id:, - billing_plan: + expired_at: ) @created_at = created_at @resource_type = resource_type @resource_id = resource_id @mode = mode - @reason = reason @expired_at = expired_at - @project_name = project_name - @region = region - @organization_name = organization_name - @organization_id = organization_id - @billing_plan = billing_plan end def self.from(map:) + map = { "$createdAt" => "", "resourceType" => "", "resourceId" => "", "mode" => "full" }.merge(map) Block.new( created_at: map["$createdAt"], resource_type: map["resourceType"], resource_id: map["resourceId"], mode: map["mode"], - reason: map["reason"], - expired_at: map["expiredAt"], - project_name: map["projectName"], - region: map["region"], - organization_name: map["organizationName"], - organization_id: map["organizationId"], - billing_plan: map["billingPlan"] + expired_at: map["expiredAt"] ) end @@ -63,13 +40,7 @@ def to_map "resourceType": @resource_type, "resourceId": @resource_id, "mode": @mode, - "reason": @reason, - "expiredAt": @expired_at, - "projectName": @project_name, - "region": @region, - "organizationName": @organization_name, - "organizationId": @organization_id, - "billingPlan": @billing_plan + "expiredAt": @expired_at } end end diff --git a/lib/appwrite/models/bucket.rb b/lib/appwrite/models/bucket.rb index c7e8af99..4729a406 100644 --- a/lib/appwrite/models/bucket.rb +++ b/lib/appwrite/models/bucket.rb @@ -51,6 +51,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "fileSecurity" => false, "name" => "", "enabled" => true, "maximumFileSize" => 0, "allowedFileExtensions" => [], "compression" => "", "encryption" => true, "antivirus" => true, "transformations" => true, "totalSize" => 0 }.merge(map) Bucket.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/bucket_list.rb b/lib/appwrite/models/bucket_list.rb index 7d3c15a2..4912786b 100644 --- a/lib/appwrite/models/bucket_list.rb +++ b/lib/appwrite/models/bucket_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "buckets" => [] }.merge(map) BucketList.new( total: map["total"], buckets: map["buckets"].map { |it| Bucket.from(map: it) } diff --git a/lib/appwrite/models/collection.rb b/lib/appwrite/models/collection.rb index 9e270f29..d0319ddd 100644 --- a/lib/appwrite/models/collection.rb +++ b/lib/appwrite/models/collection.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "databaseId" => "", "name" => "", "enabled" => true, "documentSecurity" => false, "attributes" => [], "indexes" => [], "bytesMax" => 0, "bytesUsed" => 0 }.merge(map) Collection.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/collection_list.rb b/lib/appwrite/models/collection_list.rb index e1e42d26..31b8f1b8 100644 --- a/lib/appwrite/models/collection_list.rb +++ b/lib/appwrite/models/collection_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "collections" => [] }.merge(map) CollectionList.new( total: map["total"], collections: map["collections"].map { |it| Collection.from(map: it) } diff --git a/lib/appwrite/models/column_bigint.rb b/lib/appwrite/models/column_bigint.rb index 3dfa471a..827dc9b0 100644 --- a/lib/appwrite/models/column_bigint.rb +++ b/lib/appwrite/models/column_bigint.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnBigint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_boolean.rb b/lib/appwrite/models/column_boolean.rb index 83baf4a5..24447056 100644 --- a/lib/appwrite/models/column_boolean.rb +++ b/lib/appwrite/models/column_boolean.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnBoolean.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_datetime.rb b/lib/appwrite/models/column_datetime.rb index 60122665..dc77c1b9 100644 --- a/lib/appwrite/models/column_datetime.rb +++ b/lib/appwrite/models/column_datetime.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnDatetime.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_email.rb b/lib/appwrite/models/column_email.rb index 574e47e5..94694463 100644 --- a/lib/appwrite/models/column_email.rb +++ b/lib/appwrite/models/column_email.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "email" }.merge(map) ColumnEmail.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_enum.rb b/lib/appwrite/models/column_enum.rb index 0f2bd545..6ef78955 100644 --- a/lib/appwrite/models/column_enum.rb +++ b/lib/appwrite/models/column_enum.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "elements" => [], "format" => "enum" }.merge(map) ColumnEnum.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_float.rb b/lib/appwrite/models/column_float.rb index 3c06c690..3260c161 100644 --- a/lib/appwrite/models/column_float.rb +++ b/lib/appwrite/models/column_float.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnFloat.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_index.rb b/lib/appwrite/models/column_index.rb index 478d4c23..3b4f89bc 100644 --- a/lib/appwrite/models/column_index.rb +++ b/lib/appwrite/models/column_index.rb @@ -24,7 +24,7 @@ def initialize( error:, columns:, lengths:, - orders: + orders: [] ) @id = id @created_at = created_at @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "key" => "", "type" => "", "status" => "", "error" => "", "columns" => [], "lengths" => [] }.merge(map) ColumnIndex.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/column_index_list.rb b/lib/appwrite/models/column_index_list.rb index 9278fd40..5aacf564 100644 --- a/lib/appwrite/models/column_index_list.rb +++ b/lib/appwrite/models/column_index_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "indexes" => [] }.merge(map) ColumnIndexList.new( total: map["total"], indexes: map["indexes"].map { |it| ColumnIndex.from(map: it) } diff --git a/lib/appwrite/models/column_integer.rb b/lib/appwrite/models/column_integer.rb index 0a71c44f..d58db0f7 100644 --- a/lib/appwrite/models/column_integer.rb +++ b/lib/appwrite/models/column_integer.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnInteger.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_ip.rb b/lib/appwrite/models/column_ip.rb index 3d4f6551..12b7ff0d 100644 --- a/lib/appwrite/models/column_ip.rb +++ b/lib/appwrite/models/column_ip.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "ip" }.merge(map) ColumnIp.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_line.rb b/lib/appwrite/models/column_line.rb index f8a14bf0..2ed8600e 100644 --- a/lib/appwrite/models/column_line.rb +++ b/lib/appwrite/models/column_line.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnLine.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_list.rb b/lib/appwrite/models/column_list.rb index 8d239ddf..a635a9b4 100644 --- a/lib/appwrite/models/column_list.rb +++ b/lib/appwrite/models/column_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "columns" => [] }.merge(map) ColumnList.new( total: map["total"], columns: map["columns"] diff --git a/lib/appwrite/models/column_longtext.rb b/lib/appwrite/models/column_longtext.rb index 5a112087..138b6315 100644 --- a/lib/appwrite/models/column_longtext.rb +++ b/lib/appwrite/models/column_longtext.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnLongtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_mediumtext.rb b/lib/appwrite/models/column_mediumtext.rb index c5b465c9..57fb8e40 100644 --- a/lib/appwrite/models/column_mediumtext.rb +++ b/lib/appwrite/models/column_mediumtext.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnMediumtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_point.rb b/lib/appwrite/models/column_point.rb index 34e5cf0e..b4f8cc75 100644 --- a/lib/appwrite/models/column_point.rb +++ b/lib/appwrite/models/column_point.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnPoint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_polygon.rb b/lib/appwrite/models/column_polygon.rb index 82f39732..b908f56a 100644 --- a/lib/appwrite/models/column_polygon.rb +++ b/lib/appwrite/models/column_polygon.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnPolygon.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_relationship.rb b/lib/appwrite/models/column_relationship.rb index c34643ea..22effc88 100644 --- a/lib/appwrite/models/column_relationship.rb +++ b/lib/appwrite/models/column_relationship.rb @@ -51,6 +51,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "relationType" => "", "twoWay" => false, "twoWayKey" => "", "onDelete" => "restrict", "side" => "" }.merge(map) ColumnRelationship.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_string.rb b/lib/appwrite/models/column_string.rb index 6e08f2f5..fea53cf3 100644 --- a/lib/appwrite/models/column_string.rb +++ b/lib/appwrite/models/column_string.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) ColumnString.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_text.rb b/lib/appwrite/models/column_text.rb index c3c7afb0..a72bd581 100644 --- a/lib/appwrite/models/column_text.rb +++ b/lib/appwrite/models/column_text.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnText.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_url.rb b/lib/appwrite/models/column_url.rb index 11829a7d..4cd93199 100644 --- a/lib/appwrite/models/column_url.rb +++ b/lib/appwrite/models/column_url.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "url" }.merge(map) ColumnUrl.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_varchar.rb b/lib/appwrite/models/column_varchar.rb index 1a1083d7..bf84a3e8 100644 --- a/lib/appwrite/models/column_varchar.rb +++ b/lib/appwrite/models/column_varchar.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) ColumnVarchar.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/continent.rb b/lib/appwrite/models/continent.rb index 861ec29f..64190bbc 100644 --- a/lib/appwrite/models/continent.rb +++ b/lib/appwrite/models/continent.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "code" => "" }.merge(map) Continent.new( name: map["name"], code: map["code"] diff --git a/lib/appwrite/models/continent_list.rb b/lib/appwrite/models/continent_list.rb index a5312493..f6a8c658 100644 --- a/lib/appwrite/models/continent_list.rb +++ b/lib/appwrite/models/continent_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "continents" => [] }.merge(map) ContinentList.new( total: map["total"], continents: map["continents"].map { |it| Continent.from(map: it) } diff --git a/lib/appwrite/models/country.rb b/lib/appwrite/models/country.rb index 07659799..7943e2cb 100644 --- a/lib/appwrite/models/country.rb +++ b/lib/appwrite/models/country.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "code" => "" }.merge(map) Country.new( name: map["name"], code: map["code"] diff --git a/lib/appwrite/models/country_list.rb b/lib/appwrite/models/country_list.rb index 1611dda7..7e537feb 100644 --- a/lib/appwrite/models/country_list.rb +++ b/lib/appwrite/models/country_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "countries" => [] }.merge(map) CountryList.new( total: map["total"], countries: map["countries"].map { |it| Country.from(map: it) } diff --git a/lib/appwrite/models/currency.rb b/lib/appwrite/models/currency.rb index b89e48ab..b9ebad26 100644 --- a/lib/appwrite/models/currency.rb +++ b/lib/appwrite/models/currency.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "symbol" => "", "name" => "", "symbolNative" => "", "decimalDigits" => 0, "rounding" => 0, "code" => "", "namePlural" => "" }.merge(map) Currency.new( symbol: map["symbol"], name: map["name"], diff --git a/lib/appwrite/models/currency_list.rb b/lib/appwrite/models/currency_list.rb index 53d23594..663aec21 100644 --- a/lib/appwrite/models/currency_list.rb +++ b/lib/appwrite/models/currency_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "currencies" => [] }.merge(map) CurrencyList.new( total: map["total"], currencies: map["currencies"].map { |it| Currency.from(map: it) } diff --git a/lib/appwrite/models/database.rb b/lib/appwrite/models/database.rb index d0408fc8..48d62333 100644 --- a/lib/appwrite/models/database.rb +++ b/lib/appwrite/models/database.rb @@ -54,6 +54,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "name" => "", "$createdAt" => "", "$updatedAt" => "", "enabled" => true, "type" => "legacy" }.merge(map) Database.new( id: map["$id"], name: map["name"], diff --git a/lib/appwrite/models/database_list.rb b/lib/appwrite/models/database_list.rb index 37c83aab..7b008d97 100644 --- a/lib/appwrite/models/database_list.rb +++ b/lib/appwrite/models/database_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "databases" => [] }.merge(map) DatabaseList.new( total: map["total"], databases: map["databases"].map { |it| Database.from(map: it) } diff --git a/lib/appwrite/models/database_migration.rb b/lib/appwrite/models/database_migration.rb index 75becc38..d0b4071d 100644 --- a/lib/appwrite/models/database_migration.rb +++ b/lib/appwrite/models/database_migration.rb @@ -60,6 +60,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "projectId" => "", "databaseId" => "", "specification" => "", "phase" => "pending", "attempt" => 0, "lastError" => "", "lagDocuments" => 0, "changelogWatermark" => 0, "verifiedAt" => "", "cutoverAt" => "", "soakUntil" => "", "autoCutover" => true, "cutoverRequested" => false, "paused" => false }.merge(map) DatabaseMigration.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/database_migration_list.rb b/lib/appwrite/models/database_migration_list.rb index 21730266..f42c1c2f 100644 --- a/lib/appwrite/models/database_migration_list.rb +++ b/lib/appwrite/models/database_migration_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "migrations" => [] }.merge(map) DatabaseMigrationList.new( total: map["total"], migrations: map["migrations"].map { |it| DatabaseMigration.from(map: it) } diff --git a/lib/appwrite/models/database_status.rb b/lib/appwrite/models/database_status.rb index f4a609c1..8fd8ca01 100644 --- a/lib/appwrite/models/database_status.rb +++ b/lib/appwrite/models/database_status.rb @@ -51,13 +51,14 @@ def initialize( end def self.from(map:) + map = { "health" => "unknown", "ready" => false, "engine" => "postgresql", "version" => "", "uptime" => 0, "syncMode" => "async", "syncDegraded" => false, "syncAcknowledgements" => 0, "syncStandbyCount" => 0, "replicas" => [], "volumes" => [] }.merge(map) DatabaseStatus.new( health: map["health"], ready: map["ready"], engine: map["engine"], version: map["version"], uptime: map["uptime"], - connections: DatabaseStatusConnections.from(map: map["connections"]), + connections: map["connections"].nil? ? nil : DatabaseStatusConnections.from(map: map["connections"]), sync_mode: map["syncMode"], effective_sync_mode: map["effectiveSyncMode"], sync_degraded: map["syncDegraded"], @@ -76,7 +77,7 @@ def to_map "engine": @engine, "version": @version, "uptime": @uptime, - "connections": @connections.to_map, + "connections": @connections&.to_map, "syncMode": @sync_mode, "effectiveSyncMode": @effective_sync_mode, "syncDegraded": @sync_degraded, diff --git a/lib/appwrite/models/database_status_connections.rb b/lib/appwrite/models/database_status_connections.rb index 623156df..22104215 100644 --- a/lib/appwrite/models/database_status_connections.rb +++ b/lib/appwrite/models/database_status_connections.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "current" => 0, "max" => 100 }.merge(map) DatabaseStatusConnections.new( current: map["current"], max: map["max"] diff --git a/lib/appwrite/models/database_status_replica.rb b/lib/appwrite/models/database_status_replica.rb index 7ed53873..5b499990 100644 --- a/lib/appwrite/models/database_status_replica.rb +++ b/lib/appwrite/models/database_status_replica.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "index" => 0, "role" => "unknown", "healthy" => false }.merge(map) DatabaseStatusReplica.new( index: map["index"], role: map["role"], diff --git a/lib/appwrite/models/database_status_volume.rb b/lib/appwrite/models/database_status_volume.rb index cd15505b..03c314eb 100644 --- a/lib/appwrite/models/database_status_volume.rb +++ b/lib/appwrite/models/database_status_volume.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "path" => "", "usedPercent" => "0%", "available" => "0GB", "mounted" => false }.merge(map) DatabaseStatusVolume.new( xpath: map["path"], used_percent: map["usedPercent"], diff --git a/lib/appwrite/models/dedicated_database.rb b/lib/appwrite/models/dedicated_database.rb index ca683b57..e9c87d7f 100644 --- a/lib/appwrite/models/dedicated_database.rb +++ b/lib/appwrite/models/dedicated_database.rb @@ -165,6 +165,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "projectId" => "", "name" => "", "version" => "", "specification" => "", "backend" => "", "hostname" => "", "connectionUser" => "", "connectionPassword" => "", "connectionString" => "", "ssl" => false, "status" => "provisioning", "containerStatus" => "", "lifecycleState" => "", "idleTimeoutMinutes" => 15, "cpu" => 500, "memory" => 512, "storage" => 10, "storageStatus" => "idle", "storageTargetGb" => 0, "storageClass" => "ssd", "storageMaxGb" => 0, "nodePool" => "", "replicas" => 0, "syncMode" => "", "networkMaxConnections" => 100, "networkIdleTimeoutSeconds" => 900, "networkIPAllowlist" => [], "backupEnabled" => true, "pitr" => true, "pitrRetentionDays" => 7, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, "storageAutoscalingMaxGb" => 0, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => false, "sqlApiEnabled" => true, "sqlApiAllowedStatements" => ["SELECT", "INSERT", "UPDATE", "DELETE"], "sqlApiMaxRows" => 10000, "sqlApiMaxBytes" => 10485760, "sqlApiTimeoutSeconds" => 30, "error" => "" }.merge(map) DedicatedDatabase.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/dedicated_database_backup.rb b/lib/appwrite/models/dedicated_database_backup.rb index f48b5d58..2fd522ed 100644 --- a/lib/appwrite/models/dedicated_database_backup.rb +++ b/lib/appwrite/models/dedicated_database_backup.rb @@ -60,6 +60,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "databaseId" => "", "projectId" => "", "policyId" => "", "trigger" => "manual", "type" => "full", "requestedType" => "", "fallbackReason" => "", "status" => "pending", "sizeBytes" => 0, "error" => "" }.merge(map) DedicatedDatabaseBackup.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/dedicated_database_backup_list.rb b/lib/appwrite/models/dedicated_database_backup_list.rb index 37d85ec0..c2c02187 100644 --- a/lib/appwrite/models/dedicated_database_backup_list.rb +++ b/lib/appwrite/models/dedicated_database_backup_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "backups" => [] }.merge(map) DedicatedDatabaseBackupList.new( total: map["total"], backups: map["backups"].map { |it| DedicatedDatabaseBackup.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_backup_storage.rb b/lib/appwrite/models/dedicated_database_backup_storage.rb index 3e1cb28b..aa2f1a2b 100644 --- a/lib/appwrite/models/dedicated_database_backup_storage.rb +++ b/lib/appwrite/models/dedicated_database_backup_storage.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "provider" => "", "bucket" => "", "region" => "", "prefix" => "backups/", "endpoint" => "" }.merge(map) DedicatedDatabaseBackupStorage.new( provider: map["provider"], bucket: map["bucket"], diff --git a/lib/appwrite/models/dedicated_database_branch.rb b/lib/appwrite/models/dedicated_database_branch.rb index 991728ca..52891c27 100644 --- a/lib/appwrite/models/dedicated_database_branch.rb +++ b/lib/appwrite/models/dedicated_database_branch.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "branchId" => "", "branchName" => "", "namespace" => "", "expiresAt" => 0, "host" => "", "database" => "", "username" => "", "password" => "", "ssl" => false, "engine" => "", "connectionString" => "" }.merge(map) DedicatedDatabaseBranch.new( branch_id: map["branchId"], branch_name: map["branchName"], diff --git a/lib/appwrite/models/dedicated_database_branch_list.rb b/lib/appwrite/models/dedicated_database_branch_list.rb index 106a3eb7..9ce8a978 100644 --- a/lib/appwrite/models/dedicated_database_branch_list.rb +++ b/lib/appwrite/models/dedicated_database_branch_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "branches" => [] }.merge(map) DedicatedDatabaseBranchList.new( total: map["total"], branches: map["branches"].map { |it| DedicatedDatabaseBranch.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_execution.rb b/lib/appwrite/models/dedicated_database_execution.rb index 49e247f3..8422db2d 100644 --- a/lib/appwrite/models/dedicated_database_execution.rb +++ b/lib/appwrite/models/dedicated_database_execution.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "rows" => [], "rowCount" => 0, "columns" => [], "durationMs" => 0, "truncated" => false, "bytes" => 0 }.merge(map) DedicatedDatabaseExecution.new( rows: map["rows"], row_count: map["rowCount"], diff --git a/lib/appwrite/models/dedicated_database_execution_column.rb b/lib/appwrite/models/dedicated_database_execution_column.rb index 4605650d..735dd40e 100644 --- a/lib/appwrite/models/dedicated_database_execution_column.rb +++ b/lib/appwrite/models/dedicated_database_execution_column.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "type" => "" }.merge(map) DedicatedDatabaseExecutionColumn.new( name: map["name"], type: map["type"] diff --git a/lib/appwrite/models/dedicated_database_extensions.rb b/lib/appwrite/models/dedicated_database_extensions.rb index 26c35a8e..559e09c2 100644 --- a/lib/appwrite/models/dedicated_database_extensions.rb +++ b/lib/appwrite/models/dedicated_database_extensions.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "installed" => [], "available" => [], "metadata" => [] }.merge(map) DedicatedDatabaseExtensions.new( installed: map["installed"], available: map["available"], diff --git a/lib/appwrite/models/dedicated_database_list.rb b/lib/appwrite/models/dedicated_database_list.rb index 3a66c939..79b8e45a 100644 --- a/lib/appwrite/models/dedicated_database_list.rb +++ b/lib/appwrite/models/dedicated_database_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "databases" => [] }.merge(map) DedicatedDatabaseList.new( total: map["total"], databases: map["databases"].map { |it| DedicatedDatabase.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_member.rb b/lib/appwrite/models/dedicated_database_member.rb index 8aaddc77..356dad04 100644 --- a/lib/appwrite/models/dedicated_database_member.rb +++ b/lib/appwrite/models/dedicated_database_member.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "role" => "unknown", "status" => "" }.merge(map) DedicatedDatabaseMember.new( id: map["$id"], role: map["role"], diff --git a/lib/appwrite/models/dedicated_database_operation.rb b/lib/appwrite/models/dedicated_database_operation.rb index bd6b53cf..112f0ada 100644 --- a/lib/appwrite/models/dedicated_database_operation.rb +++ b/lib/appwrite/models/dedicated_database_operation.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "databaseId" => "", "type" => "", "status" => "", "attempts" => 0, "errorCode" => "", "errorMessage" => "" }.merge(map) DedicatedDatabaseOperation.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/dedicated_database_operation_list.rb b/lib/appwrite/models/dedicated_database_operation_list.rb index d4985739..8b63a84b 100644 --- a/lib/appwrite/models/dedicated_database_operation_list.rb +++ b/lib/appwrite/models/dedicated_database_operation_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "operations" => [] }.merge(map) DedicatedDatabaseOperationList.new( total: map["total"], operations: map["operations"].map { |it| DedicatedDatabaseOperation.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_pitr_windows.rb b/lib/appwrite/models/dedicated_database_pitr_windows.rb index b80d115d..492f5bac 100644 --- a/lib/appwrite/models/dedicated_database_pitr_windows.rb +++ b/lib/appwrite/models/dedicated_database_pitr_windows.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "earliest" => "", "latest" => "" }.merge(map) DedicatedDatabasePITRWindows.new( earliest: map["earliest"], latest: map["latest"] diff --git a/lib/appwrite/models/dedicated_database_pooler.rb b/lib/appwrite/models/dedicated_database_pooler.rb index a87c1776..1804c09c 100644 --- a/lib/appwrite/models/dedicated_database_pooler.rb +++ b/lib/appwrite/models/dedicated_database_pooler.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => false, "mode" => "transaction", "maxConnections" => 100, "defaultPoolSize" => 20, "port" => 6432, "readWriteSplitting" => false, "poolerCpuRequest" => "", "poolerCpuLimit" => "", "poolerMemoryRequest" => "", "poolerMemoryLimit" => "" }.merge(map) DedicatedDatabasePooler.new( enabled: map["enabled"], mode: map["mode"], diff --git a/lib/appwrite/models/dedicated_database_replicas.rb b/lib/appwrite/models/dedicated_database_replicas.rb index 72106776..409c8b07 100644 --- a/lib/appwrite/models/dedicated_database_replicas.rb +++ b/lib/appwrite/models/dedicated_database_replicas.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "replicas" => 0, "syncMode" => "async", "syncDegraded" => false, "syncAcknowledgements" => 0, "syncStandbyCount" => 0, "members" => [] }.merge(map) DedicatedDatabaseReplicas.new( replicas: map["replicas"], sync_mode: map["syncMode"], diff --git a/lib/appwrite/models/dedicated_database_restoration.rb b/lib/appwrite/models/dedicated_database_restoration.rb index be6e9f26..8d4579a6 100644 --- a/lib/appwrite/models/dedicated_database_restoration.rb +++ b/lib/appwrite/models/dedicated_database_restoration.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "databaseId" => "", "projectId" => "", "type" => "backup", "status" => "pending", "error" => "" }.merge(map) DedicatedDatabaseRestoration.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/dedicated_database_restoration_list.rb b/lib/appwrite/models/dedicated_database_restoration_list.rb index dcb3f9ee..7755ec27 100644 --- a/lib/appwrite/models/dedicated_database_restoration_list.rb +++ b/lib/appwrite/models/dedicated_database_restoration_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "restorations" => [] }.merge(map) DedicatedDatabaseRestorationList.new( total: map["total"], restorations: map["restorations"].map { |it| DedicatedDatabaseRestoration.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_specification.rb b/lib/appwrite/models/dedicated_database_specification.rb index b5f26a33..2c0bc719 100644 --- a/lib/appwrite/models/dedicated_database_specification.rb +++ b/lib/appwrite/models/dedicated_database_specification.rb @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "slug" => "", "name" => "", "price" => 0, "storageOverageRate" => 0, "bandwidthOverageRate" => 0, "replicaRate" => 0, "pitrRate" => 0, "cpu" => 0, "memory" => 0, "maxConnections" => 0, "includedStorage" => 0, "includedBandwidth" => 0, "enabled" => false }.merge(map) DedicatedDatabaseSpecification.new( slug: map["slug"], name: map["name"], diff --git a/lib/appwrite/models/dedicated_database_specification_list.rb b/lib/appwrite/models/dedicated_database_specification_list.rb index 206eec28..e649aa18 100644 --- a/lib/appwrite/models/dedicated_database_specification_list.rb +++ b/lib/appwrite/models/dedicated_database_specification_list.rb @@ -5,31 +5,27 @@ module Models class DedicatedDatabaseSpecificationList attr_reader :specifications attr_reader :total - attr_reader :pricing def initialize( specifications:, - total:, - pricing: + total: ) @specifications = specifications @total = total - @pricing = pricing end def self.from(map:) + map = { "specifications" => [], "total" => 0 }.merge(map) DedicatedDatabaseSpecificationList.new( specifications: map["specifications"].map { |it| DedicatedDatabaseSpecification.from(map: it) }, - total: map["total"], - pricing: DedicatedDatabaseSpecificationPricing.from(map: map["pricing"]) + total: map["total"] ) end def to_map { "specifications": @specifications.map { |it| it.to_map }, - "total": @total, - "pricing": @pricing.to_map + "total": @total } end end diff --git a/lib/appwrite/models/dedicated_database_specification_pricing.rb b/lib/appwrite/models/dedicated_database_specification_pricing.rb deleted file mode 100644 index d6ef0ef8..00000000 --- a/lib/appwrite/models/dedicated_database_specification_pricing.rb +++ /dev/null @@ -1,42 +0,0 @@ -# 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 :pitr_rate - - def initialize( - storage_overage_rate:, - bandwidth_overage_rate:, - replica_rate:, - pitr_rate: - ) - @storage_overage_rate = storage_overage_rate - @bandwidth_overage_rate = bandwidth_overage_rate - @replica_rate = 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"], - pitr_rate: map["pitrRate"] - ) - end - - def to_map - { - "storageOverageRate": @storage_overage_rate, - "bandwidthOverageRate": @bandwidth_overage_rate, - "replicaRate": @replica_rate, - "pitrRate": @pitr_rate - } - end - end - end -end diff --git a/lib/appwrite/models/deployment.rb b/lib/appwrite/models/deployment.rb index 6fc3465b..c4749311 100644 --- a/lib/appwrite/models/deployment.rb +++ b/lib/appwrite/models/deployment.rb @@ -90,6 +90,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "type" => "", "resourceId" => "", "resourceType" => "", "entrypoint" => "", "sourceSize" => 0, "buildSize" => 0, "totalSize" => 0, "buildId" => "", "activate" => false, "screenshotLight" => "", "screenshotDark" => "", "buildLogs" => "", "buildDuration" => 0, "providerRepositoryName" => "", "providerRepositoryOwner" => "", "providerRepositoryUrl" => "", "providerCommitHash" => "", "providerCommitAuthorUrl" => "", "providerCommitAuthor" => "", "providerCommitMessage" => "", "providerCommitUrl" => "", "providerBranch" => "", "providerBranchUrl" => "" }.merge(map) Deployment.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/deployment_list.rb b/lib/appwrite/models/deployment_list.rb index f9a2d696..5ff996f5 100644 --- a/lib/appwrite/models/deployment_list.rb +++ b/lib/appwrite/models/deployment_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "deployments" => [] }.merge(map) DeploymentList.new( total: map["total"], deployments: map["deployments"].map { |it| Deployment.from(map: it) } diff --git a/lib/appwrite/models/dev_key.rb b/lib/appwrite/models/dev_key.rb deleted file mode 100644 index 4389e82a..00000000 --- a/lib/appwrite/models/dev_key.rb +++ /dev/null @@ -1,62 +0,0 @@ -# frozen_string_literal: true - -module Appwrite - module Models - class DevKey - attr_reader :id - attr_reader :created_at - attr_reader :updated_at - attr_reader :name - attr_reader :expire - attr_reader :secret - attr_reader :accessed_at - attr_reader :sdks - - def initialize( - id:, - created_at:, - updated_at:, - name:, - expire:, - secret:, - accessed_at:, - sdks: - ) - @id = id - @created_at = created_at - @updated_at = updated_at - @name = name - @expire = expire - @secret = secret - @accessed_at = accessed_at - @sdks = sdks - end - - def self.from(map:) - DevKey.new( - id: map["$id"], - created_at: map["$createdAt"], - updated_at: map["$updatedAt"], - name: map["name"], - expire: map["expire"], - secret: map["secret"], - accessed_at: map["accessedAt"], - sdks: map["sdks"] - ) - end - - def to_map - { - "$id": @id, - "$createdAt": @created_at, - "$updatedAt": @updated_at, - "name": @name, - "expire": @expire, - "secret": @secret, - "accessedAt": @accessed_at, - "sdks": @sdks - } - end - end - end -end diff --git a/lib/appwrite/models/document.rb b/lib/appwrite/models/document.rb index 0cc8a466..02ed60e3 100644 --- a/lib/appwrite/models/document.rb +++ b/lib/appwrite/models/document.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$sequence" => "", "$collectionId" => "", "$databaseId" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [] }.merge(map) Document.new( id: map["$id"], sequence: map["$sequence"], diff --git a/lib/appwrite/models/document_list.rb b/lib/appwrite/models/document_list.rb index 254e19e2..9a1c4f69 100644 --- a/lib/appwrite/models/document_list.rb +++ b/lib/appwrite/models/document_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "documents" => [] }.merge(map) DocumentList.new( total: map["total"], documents: map["documents"].map { |it| Document.from(map: it) } diff --git a/lib/appwrite/models/email_template.rb b/lib/appwrite/models/email_template.rb index 5cacd768..ee13cfb6 100644 --- a/lib/appwrite/models/email_template.rb +++ b/lib/appwrite/models/email_template.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "templateId" => "", "locale" => "", "message" => "", "senderName" => "", "senderEmail" => "", "replyToEmail" => "", "replyToName" => "", "subject" => "" }.merge(map) EmailTemplate.new( template_id: map["templateId"], locale: map["locale"], diff --git a/lib/appwrite/models/email_template_list.rb b/lib/appwrite/models/email_template_list.rb index fbc649f1..4334c55c 100644 --- a/lib/appwrite/models/email_template_list.rb +++ b/lib/appwrite/models/email_template_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "templates" => [] }.merge(map) EmailTemplateList.new( total: map["total"], templates: map["templates"].map { |it| EmailTemplate.from(map: it) } diff --git a/lib/appwrite/models/embedding.rb b/lib/appwrite/models/embedding.rb index 177a94f4..f7c9978d 100644 --- a/lib/appwrite/models/embedding.rb +++ b/lib/appwrite/models/embedding.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "model" => "", "dimension" => 0, "embedding" => [], "error" => "" }.merge(map) Embedding.new( model: map["model"], dimension: map["dimension"], diff --git a/lib/appwrite/models/embedding_list.rb b/lib/appwrite/models/embedding_list.rb index 848b50d4..10090e93 100644 --- a/lib/appwrite/models/embedding_list.rb +++ b/lib/appwrite/models/embedding_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "embeddings" => [] }.merge(map) EmbeddingList.new( total: map["total"], embeddings: map["embeddings"].map { |it| Embedding.from(map: it) } diff --git a/lib/appwrite/models/ephemeral_key.rb b/lib/appwrite/models/ephemeral_key.rb index 14761c4f..cdc9eb77 100644 --- a/lib/appwrite/models/ephemeral_key.rb +++ b/lib/appwrite/models/ephemeral_key.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "expire" => "", "scopes" => [], "secret" => "", "accessedAt" => "", "sdks" => [] }.merge(map) EphemeralKey.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/execution.rb b/lib/appwrite/models/execution.rb index 55a701d5..d95bbbfe 100644 --- a/lib/appwrite/models/execution.rb +++ b/lib/appwrite/models/execution.rb @@ -66,6 +66,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "resourceId" => "", "resourceType" => "functions", "deploymentId" => "", "requestMethod" => "", "requestPath" => "", "requestHeaders" => [], "responseStatusCode" => 0, "responseBody" => "", "responseHeaders" => [], "logs" => "", "errors" => "", "duration" => 0 }.merge(map) Execution.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/execution_list.rb b/lib/appwrite/models/execution_list.rb index 531551db..457400c3 100644 --- a/lib/appwrite/models/execution_list.rb +++ b/lib/appwrite/models/execution_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "executions" => [] }.merge(map) ExecutionList.new( total: map["total"], executions: map["executions"].map { |it| Execution.from(map: it) } diff --git a/lib/appwrite/models/file.rb b/lib/appwrite/models/file.rb index 66ee936b..d448ece2 100644 --- a/lib/appwrite/models/file.rb +++ b/lib/appwrite/models/file.rb @@ -57,6 +57,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "bucketId" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "name" => "", "folder" => "", "key" => "", "signature" => "", "mimeType" => "", "sizeOriginal" => 0, "sizeActual" => 0, "chunksTotal" => 0, "chunksUploaded" => 0, "encryption" => false, "compression" => "none" }.merge(map) File.new( id: map["$id"], bucket_id: map["bucketId"], diff --git a/lib/appwrite/models/file_list.rb b/lib/appwrite/models/file_list.rb index 7a033d5a..9aee37f8 100644 --- a/lib/appwrite/models/file_list.rb +++ b/lib/appwrite/models/file_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "files" => [] }.merge(map) FileList.new( total: map["total"], files: map["files"].map { |it| File.from(map: it) } diff --git a/lib/appwrite/models/framework.rb b/lib/appwrite/models/framework.rb index 98108bfe..4dcc1d52 100644 --- a/lib/appwrite/models/framework.rb +++ b/lib/appwrite/models/framework.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "name" => "", "buildRuntime" => "", "runtimes" => [], "adapters" => [] }.merge(map) Framework.new( key: map["key"], name: map["name"], diff --git a/lib/appwrite/models/framework_adapter.rb b/lib/appwrite/models/framework_adapter.rb index 81d06e20..7a35dce5 100644 --- a/lib/appwrite/models/framework_adapter.rb +++ b/lib/appwrite/models/framework_adapter.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "installCommand" => "", "buildCommand" => "", "outputDirectory" => "" }.merge(map) FrameworkAdapter.new( key: map["key"], install_command: map["installCommand"], diff --git a/lib/appwrite/models/framework_list.rb b/lib/appwrite/models/framework_list.rb index da86b56d..7f477fe7 100644 --- a/lib/appwrite/models/framework_list.rb +++ b/lib/appwrite/models/framework_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "frameworks" => [] }.merge(map) FrameworkList.new( total: map["total"], frameworks: map["frameworks"].map { |it| Framework.from(map: it) } diff --git a/lib/appwrite/models/function.rb b/lib/appwrite/models/function.rb index 6d8b38b7..a89407be 100644 --- a/lib/appwrite/models/function.rb +++ b/lib/appwrite/models/function.rb @@ -57,7 +57,7 @@ def initialize( vars:, events:, schedule:, - interval:, + interval: 0, timeout:, entrypoint:, commands:, @@ -108,6 +108,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "execute" => [], "name" => "", "enabled" => true, "live" => true, "logging" => true, "runtime" => "", "deploymentRetention" => 0, "deploymentId" => "", "deploymentCreatedAt" => "", "latestDeploymentId" => "", "latestDeploymentCreatedAt" => "", "latestDeploymentStatus" => "", "scopes" => [], "vars" => [], "events" => [], "schedule" => "", "timeout" => 15, "entrypoint" => "", "commands" => "", "version" => "v5", "installationId" => "", "providerRepositoryId" => "", "providerBranch" => "", "providerRootDirectory" => "", "providerSilentMode" => false, "providerBranches" => [], "providerPaths" => [], "buildSpecification" => "s-1vcpu-512mb", "runtimeSpecification" => "s-1vcpu-512mb" }.merge(map) Function.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/function_list.rb b/lib/appwrite/models/function_list.rb index 8ac71cf1..554fdeb2 100644 --- a/lib/appwrite/models/function_list.rb +++ b/lib/appwrite/models/function_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "functions" => [] }.merge(map) FunctionList.new( total: map["total"], functions: map["functions"].map { |it| Function.from(map: it) } diff --git a/lib/appwrite/models/headers.rb b/lib/appwrite/models/headers.rb index 5c43bea8..270773e3 100644 --- a/lib/appwrite/models/headers.rb +++ b/lib/appwrite/models/headers.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "value" => "" }.merge(map) Headers.new( name: map["name"], value: map["value"] diff --git a/lib/appwrite/models/identity.rb b/lib/appwrite/models/identity.rb index abf586a2..4261f302 100644 --- a/lib/appwrite/models/identity.rb +++ b/lib/appwrite/models/identity.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "provider" => "", "providerUid" => "", "providerEmail" => "", "providerAccessToken" => "", "providerAccessTokenExpiry" => "", "providerRefreshToken" => "", "providerIdToken" => "" }.merge(map) Identity.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/identity_list.rb b/lib/appwrite/models/identity_list.rb index bef444be..18d48d2f 100644 --- a/lib/appwrite/models/identity_list.rb +++ b/lib/appwrite/models/identity_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "identities" => [] }.merge(map) IdentityList.new( total: map["total"], identities: map["identities"].map { |it| Identity.from(map: it) } diff --git a/lib/appwrite/models/index.rb b/lib/appwrite/models/index.rb index 20b6e62b..da063ec1 100644 --- a/lib/appwrite/models/index.rb +++ b/lib/appwrite/models/index.rb @@ -24,7 +24,7 @@ def initialize( error:, attributes:, lengths:, - orders: + orders: [] ) @id = id @created_at = created_at @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "key" => "", "type" => "", "error" => "", "attributes" => [], "lengths" => [] }.merge(map) Index.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/index_list.rb b/lib/appwrite/models/index_list.rb index a0795d16..a096b0c2 100644 --- a/lib/appwrite/models/index_list.rb +++ b/lib/appwrite/models/index_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "indexes" => [] }.merge(map) IndexList.new( total: map["total"], indexes: map["indexes"].map { |it| Index.from(map: it) } diff --git a/lib/appwrite/models/insight.rb b/lib/appwrite/models/insight.rb index a10df160..f2ede1a1 100644 --- a/lib/appwrite/models/insight.rb +++ b/lib/appwrite/models/insight.rb @@ -60,6 +60,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "reportId" => "", "type" => "", "severity" => "info", "status" => "active", "resourceType" => "", "resourceId" => "", "parentResourceType" => "", "parentResourceId" => "", "title" => "", "summary" => "", "ctas" => [] }.merge(map) Insight.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/insight_cta.rb b/lib/appwrite/models/insight_cta.rb index 36670cbe..1a92a732 100644 --- a/lib/appwrite/models/insight_cta.rb +++ b/lib/appwrite/models/insight_cta.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "label" => "", "service" => "", "method" => "", "params" => {} }.merge(map) InsightCTA.new( label: map["label"], service: map["service"], diff --git a/lib/appwrite/models/insight_list.rb b/lib/appwrite/models/insight_list.rb index af19aa84..70a1285b 100644 --- a/lib/appwrite/models/insight_list.rb +++ b/lib/appwrite/models/insight_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "insights" => [] }.merge(map) InsightList.new( total: map["total"], insights: map["insights"].map { |it| Insight.from(map: it) } diff --git a/lib/appwrite/models/jwt.rb b/lib/appwrite/models/jwt.rb index 73d8c92c..af1e7eb8 100644 --- a/lib/appwrite/models/jwt.rb +++ b/lib/appwrite/models/jwt.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "jwt" => "" }.merge(map) Jwt.new( jwt: map["jwt"] ) diff --git a/lib/appwrite/models/key.rb b/lib/appwrite/models/key.rb index 4df47cf3..5eb79318 100644 --- a/lib/appwrite/models/key.rb +++ b/lib/appwrite/models/key.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "expire" => "", "scopes" => [], "secret" => "", "accessedAt" => "", "sdks" => [] }.merge(map) Key.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/key_list.rb b/lib/appwrite/models/key_list.rb index d7a9649f..ac413cff 100644 --- a/lib/appwrite/models/key_list.rb +++ b/lib/appwrite/models/key_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "keys" => [] }.merge(map) KeyList.new( total: map["total"], keys: map["keys"].map { |it| Key.from(map: it) } diff --git a/lib/appwrite/models/language.rb b/lib/appwrite/models/language.rb index 8850a69b..b2acb8d8 100644 --- a/lib/appwrite/models/language.rb +++ b/lib/appwrite/models/language.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "code" => "", "nativeName" => "" }.merge(map) Language.new( name: map["name"], code: map["code"], diff --git a/lib/appwrite/models/language_list.rb b/lib/appwrite/models/language_list.rb index 118fc410..ec55d81e 100644 --- a/lib/appwrite/models/language_list.rb +++ b/lib/appwrite/models/language_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "languages" => [] }.merge(map) LanguageList.new( total: map["total"], languages: map["languages"].map { |it| Language.from(map: it) } diff --git a/lib/appwrite/models/locale.rb b/lib/appwrite/models/locale.rb index a31aea64..1fcb8607 100644 --- a/lib/appwrite/models/locale.rb +++ b/lib/appwrite/models/locale.rb @@ -63,6 +63,7 @@ def initialize( end def self.from(map:) + map = { "ip" => "", "countryCode" => "", "country" => "", "continentCode" => "", "continent" => "", "eu" => false, "currency" => "" }.merge(map) Locale.new( ip: map["ip"], country_code: map["countryCode"], diff --git a/lib/appwrite/models/locale_code.rb b/lib/appwrite/models/locale_code.rb index 6089272b..4795135c 100644 --- a/lib/appwrite/models/locale_code.rb +++ b/lib/appwrite/models/locale_code.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "code" => "", "name" => "" }.merge(map) LocaleCode.new( code: map["code"], name: map["name"] diff --git a/lib/appwrite/models/locale_code_list.rb b/lib/appwrite/models/locale_code_list.rb index b93213cb..e771b6d7 100644 --- a/lib/appwrite/models/locale_code_list.rb +++ b/lib/appwrite/models/locale_code_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "localeCodes" => [] }.merge(map) LocaleCodeList.new( total: map["total"], locale_codes: map["localeCodes"].map { |it| LocaleCode.from(map: it) } diff --git a/lib/appwrite/models/log.rb b/lib/appwrite/models/log.rb deleted file mode 100644 index 89e1a676..00000000 --- a/lib/appwrite/models/log.rb +++ /dev/null @@ -1,132 +0,0 @@ -# frozen_string_literal: true - -module Appwrite - module Models - class Log - attr_reader :event - attr_reader :user_id - attr_reader :user_email - attr_reader :user_name - attr_reader :mode - attr_reader :user_type - attr_reader :ip - attr_reader :time - attr_reader :os_code - attr_reader :os_name - attr_reader :os_version - attr_reader :client_type - attr_reader :client_code - attr_reader :client_name - attr_reader :client_version - attr_reader :client_engine - attr_reader :client_engine_version - attr_reader :device_name - attr_reader :device_brand - attr_reader :device_model - attr_reader :country_code - attr_reader :country_name - - def initialize( - event:, - user_id:, - user_email:, - user_name:, - mode:, - user_type:, - ip:, - time:, - os_code:, - os_name:, - os_version:, - client_type:, - client_code:, - client_name:, - client_version:, - client_engine:, - client_engine_version:, - device_name:, - device_brand:, - device_model:, - country_code:, - country_name: - ) - @event = event - @user_id = user_id - @user_email = user_email - @user_name = user_name - @mode = mode - @user_type = user_type - @ip = ip - @time = time - @os_code = os_code - @os_name = os_name - @os_version = os_version - @client_type = client_type - @client_code = client_code - @client_name = client_name - @client_version = client_version - @client_engine = client_engine - @client_engine_version = client_engine_version - @device_name = device_name - @device_brand = device_brand - @device_model = device_model - @country_code = country_code - @country_name = country_name - end - - def self.from(map:) - Log.new( - event: map["event"], - user_id: map["userId"], - user_email: map["userEmail"], - user_name: map["userName"], - mode: map["mode"], - user_type: map["userType"], - ip: map["ip"], - time: map["time"], - os_code: map["osCode"], - os_name: map["osName"], - os_version: map["osVersion"], - client_type: map["clientType"], - client_code: map["clientCode"], - client_name: map["clientName"], - client_version: map["clientVersion"], - client_engine: map["clientEngine"], - client_engine_version: map["clientEngineVersion"], - device_name: map["deviceName"], - device_brand: map["deviceBrand"], - device_model: map["deviceModel"], - country_code: map["countryCode"], - country_name: map["countryName"] - ) - end - - def to_map - { - "event": @event, - "userId": @user_id, - "userEmail": @user_email, - "userName": @user_name, - "mode": @mode, - "userType": @user_type, - "ip": @ip, - "time": @time, - "osCode": @os_code, - "osName": @os_name, - "osVersion": @os_version, - "clientType": @client_type, - "clientCode": @client_code, - "clientName": @client_name, - "clientVersion": @client_version, - "clientEngine": @client_engine, - "clientEngineVersion": @client_engine_version, - "deviceName": @device_name, - "deviceBrand": @device_brand, - "deviceModel": @device_model, - "countryCode": @country_code, - "countryName": @country_name - } - end - end - end -end diff --git a/lib/appwrite/models/log_list.rb b/lib/appwrite/models/log_list.rb deleted file mode 100644 index cdad965e..00000000 --- a/lib/appwrite/models/log_list.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -module Appwrite - module Models - class LogList - attr_reader :total - attr_reader :logs - - def initialize( - total:, - logs: - ) - @total = total - @logs = logs - end - - def self.from(map:) - LogList.new( - total: map["total"], - logs: map["logs"].map { |it| Log.from(map: it) } - ) - end - - def to_map - { - "total": @total, - "logs": @logs.map { |it| it.to_map } - } - end - end - end -end diff --git a/lib/appwrite/models/membership.rb b/lib/appwrite/models/membership.rb index 84b3ce1f..61e20c1d 100644 --- a/lib/appwrite/models/membership.rb +++ b/lib/appwrite/models/membership.rb @@ -54,6 +54,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "userName" => "", "userEmail" => "", "userPhone" => "", "teamId" => "", "teamName" => "", "invited" => "", "joined" => "", "confirm" => false, "mfa" => false, "userAccessedAt" => "", "roles" => [] }.merge(map) Membership.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/membership_list.rb b/lib/appwrite/models/membership_list.rb index 0cc220c0..dceb8db0 100644 --- a/lib/appwrite/models/membership_list.rb +++ b/lib/appwrite/models/membership_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "memberships" => [] }.merge(map) MembershipList.new( total: map["total"], memberships: map["memberships"].map { |it| Membership.from(map: it) } diff --git a/lib/appwrite/models/message.rb b/lib/appwrite/models/message.rb index 456afe3a..49b032df 100644 --- a/lib/appwrite/models/message.rb +++ b/lib/appwrite/models/message.rb @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "providerType" => "", "topics" => [], "users" => [], "targets" => [], "deliveredTotal" => 0, "data" => {}, "status" => "draft" }.merge(map) Message.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/message_list.rb b/lib/appwrite/models/message_list.rb index 50175444..d3930021 100644 --- a/lib/appwrite/models/message_list.rb +++ b/lib/appwrite/models/message_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "messages" => [] }.merge(map) MessageList.new( total: map["total"], messages: map["messages"].map { |it| Message.from(map: it) } diff --git a/lib/appwrite/models/mfa_challenge.rb b/lib/appwrite/models/mfa_challenge.rb index 6ba21fef..384f9031 100644 --- a/lib/appwrite/models/mfa_challenge.rb +++ b/lib/appwrite/models/mfa_challenge.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "expire" => "" }.merge(map) MfaChallenge.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/mfa_challenge_secret.rb b/lib/appwrite/models/mfa_challenge_secret.rb index ad8abbcd..36cb2e7d 100644 --- a/lib/appwrite/models/mfa_challenge_secret.rb +++ b/lib/appwrite/models/mfa_challenge_secret.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "expire" => "", "code" => "" }.merge(map) MfaChallengeSecret.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/mfa_factors.rb b/lib/appwrite/models/mfa_factors.rb index 55b58ca2..55db99ea 100644 --- a/lib/appwrite/models/mfa_factors.rb +++ b/lib/appwrite/models/mfa_factors.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "totp" => false, "phone" => false, "email" => false, "recoveryCode" => false, "custom" => false }.merge(map) MfaFactors.new( totp: map["totp"], phone: map["phone"], diff --git a/lib/appwrite/models/mfa_recovery_codes.rb b/lib/appwrite/models/mfa_recovery_codes.rb index 1fd53c11..c9097acb 100644 --- a/lib/appwrite/models/mfa_recovery_codes.rb +++ b/lib/appwrite/models/mfa_recovery_codes.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "recoveryCodes" => [] }.merge(map) MfaRecoveryCodes.new( recovery_codes: map["recoveryCodes"] ) diff --git a/lib/appwrite/models/mfa_type.rb b/lib/appwrite/models/mfa_type.rb index 0612dc2d..4a8c7482 100644 --- a/lib/appwrite/models/mfa_type.rb +++ b/lib/appwrite/models/mfa_type.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "secret" => "", "uri" => "" }.merge(map) MfaType.new( secret: map["secret"], uri: map["uri"] diff --git a/lib/appwrite/models/mock_number.rb b/lib/appwrite/models/mock_number.rb index 59d96f27..8bb41c9b 100644 --- a/lib/appwrite/models/mock_number.rb +++ b/lib/appwrite/models/mock_number.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "number" => "", "otp" => "", "$createdAt" => "", "$updatedAt" => "" }.merge(map) MockNumber.new( number: map["number"], otp: map["otp"], diff --git a/lib/appwrite/models/mock_number_list.rb b/lib/appwrite/models/mock_number_list.rb index 56a7fdd2..ca3a9af1 100644 --- a/lib/appwrite/models/mock_number_list.rb +++ b/lib/appwrite/models/mock_number_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "mockNumbers" => [] }.merge(map) MockNumberList.new( total: map["total"], mock_numbers: map["mockNumbers"].map { |it| MockNumber.from(map: it) } diff --git a/lib/appwrite/models/o_auth2_amazon.rb b/lib/appwrite/models/o_auth2_amazon.rb index 177ce121..1afa9f98 100644 --- a/lib/appwrite/models/o_auth2_amazon.rb +++ b/lib/appwrite/models/o_auth2_amazon.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Amazon.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_apple.rb b/lib/appwrite/models/o_auth2_apple.rb index f5949d06..ed1b5058 100644 --- a/lib/appwrite/models/o_auth2_apple.rb +++ b/lib/appwrite/models/o_auth2_apple.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "serviceId" => "", "keyId" => "", "teamId" => "", "p8File" => "", "nativeEnabled" => false, "nativeClientIds" => [] }.merge(map) OAuth2Apple.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_appwrite.rb b/lib/appwrite/models/o_auth2_appwrite.rb index c12a6b55..e9624285 100644 --- a/lib/appwrite/models/o_auth2_appwrite.rb +++ b/lib/appwrite/models/o_auth2_appwrite.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Appwrite.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_auth0.rb b/lib/appwrite/models/o_auth2_auth0.rb index e9cf3cb0..0625fe06 100644 --- a/lib/appwrite/models/o_auth2_auth0.rb +++ b/lib/appwrite/models/o_auth2_auth0.rb @@ -22,11 +22,12 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) @endpoint = endpoint end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [], "endpoint" => "" }.merge(map) OAuth2Auth0.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_authentik.rb b/lib/appwrite/models/o_auth2_authentik.rb index 81fc7ff8..643597f5 100644 --- a/lib/appwrite/models/o_auth2_authentik.rb +++ b/lib/appwrite/models/o_auth2_authentik.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "endpoint" => "" }.merge(map) OAuth2Authentik.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_autodesk.rb b/lib/appwrite/models/o_auth2_autodesk.rb index f260b12e..fa2a8d98 100644 --- a/lib/appwrite/models/o_auth2_autodesk.rb +++ b/lib/appwrite/models/o_auth2_autodesk.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Autodesk.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_bitbucket.rb b/lib/appwrite/models/o_auth2_bitbucket.rb index 44509504..f4686ebc 100644 --- a/lib/appwrite/models/o_auth2_bitbucket.rb +++ b/lib/appwrite/models/o_auth2_bitbucket.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "key" => "", "secret" => "" }.merge(map) OAuth2Bitbucket.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_bitly.rb b/lib/appwrite/models/o_auth2_bitly.rb index ad116ed0..a9efb469 100644 --- a/lib/appwrite/models/o_auth2_bitly.rb +++ b/lib/appwrite/models/o_auth2_bitly.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Bitly.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_box.rb b/lib/appwrite/models/o_auth2_box.rb index 7cdfedd0..e2aa2269 100644 --- a/lib/appwrite/models/o_auth2_box.rb +++ b/lib/appwrite/models/o_auth2_box.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Box.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_cloudflare.rb b/lib/appwrite/models/o_auth2_cloudflare.rb index 7f3e65bf..f0bc5549 100644 --- a/lib/appwrite/models/o_auth2_cloudflare.rb +++ b/lib/appwrite/models/o_auth2_cloudflare.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Cloudflare.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_dailymotion.rb b/lib/appwrite/models/o_auth2_dailymotion.rb index 31e10ed1..241d92c7 100644 --- a/lib/appwrite/models/o_auth2_dailymotion.rb +++ b/lib/appwrite/models/o_auth2_dailymotion.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "apiKey" => "", "apiSecret" => "" }.merge(map) OAuth2Dailymotion.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_discord.rb b/lib/appwrite/models/o_auth2_discord.rb index 5d7db0cb..972672bd 100644 --- a/lib/appwrite/models/o_auth2_discord.rb +++ b/lib/appwrite/models/o_auth2_discord.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [] }.merge(map) OAuth2Discord.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_disqus.rb b/lib/appwrite/models/o_auth2_disqus.rb index 2b8e4261..e1670515 100644 --- a/lib/appwrite/models/o_auth2_disqus.rb +++ b/lib/appwrite/models/o_auth2_disqus.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "publicKey" => "", "secretKey" => "" }.merge(map) OAuth2Disqus.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_dropbox.rb b/lib/appwrite/models/o_auth2_dropbox.rb index d5581312..d57c294d 100644 --- a/lib/appwrite/models/o_auth2_dropbox.rb +++ b/lib/appwrite/models/o_auth2_dropbox.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "appKey" => "", "appSecret" => "" }.merge(map) OAuth2Dropbox.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_etsy.rb b/lib/appwrite/models/o_auth2_etsy.rb index 87acab75..2af4595a 100644 --- a/lib/appwrite/models/o_auth2_etsy.rb +++ b/lib/appwrite/models/o_auth2_etsy.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "keyString" => "", "sharedSecret" => "" }.merge(map) OAuth2Etsy.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_facebook.rb b/lib/appwrite/models/o_auth2_facebook.rb index f42ab1e7..6a6206de 100644 --- a/lib/appwrite/models/o_auth2_facebook.rb +++ b/lib/appwrite/models/o_auth2_facebook.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "appId" => "", "appSecret" => "" }.merge(map) OAuth2Facebook.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_figma.rb b/lib/appwrite/models/o_auth2_figma.rb index 7da8c796..2470388c 100644 --- a/lib/appwrite/models/o_auth2_figma.rb +++ b/lib/appwrite/models/o_auth2_figma.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Figma.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_fusion_auth.rb b/lib/appwrite/models/o_auth2_fusion_auth.rb index 74e205e3..28bf8307 100644 --- a/lib/appwrite/models/o_auth2_fusion_auth.rb +++ b/lib/appwrite/models/o_auth2_fusion_auth.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "endpoint" => "" }.merge(map) OAuth2FusionAuth.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_github.rb b/lib/appwrite/models/o_auth2_github.rb index d46e1e38..66986a27 100644 --- a/lib/appwrite/models/o_auth2_github.rb +++ b/lib/appwrite/models/o_auth2_github.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [] }.merge(map) OAuth2Github.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_gitlab.rb b/lib/appwrite/models/o_auth2_gitlab.rb index 2f1d2237..5a7b7f5b 100644 --- a/lib/appwrite/models/o_auth2_gitlab.rb +++ b/lib/appwrite/models/o_auth2_gitlab.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "applicationId" => "", "secret" => "", "endpoint" => "" }.merge(map) OAuth2Gitlab.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_google.rb b/lib/appwrite/models/o_auth2_google.rb index b646c30d..be1959fd 100644 --- a/lib/appwrite/models/o_auth2_google.rb +++ b/lib/appwrite/models/o_auth2_google.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => ["consent"], "nativeEnabled" => false, "nativeClientIds" => [] }.merge(map) OAuth2Google.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_hugging_face.rb b/lib/appwrite/models/o_auth2_hugging_face.rb index c75e13cc..43430cb0 100644 --- a/lib/appwrite/models/o_auth2_hugging_face.rb +++ b/lib/appwrite/models/o_auth2_hugging_face.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2HuggingFace.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_keycloak.rb b/lib/appwrite/models/o_auth2_keycloak.rb index 6af51b90..3e432d14 100644 --- a/lib/appwrite/models/o_auth2_keycloak.rb +++ b/lib/appwrite/models/o_auth2_keycloak.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "endpoint" => "", "realmName" => "" }.merge(map) OAuth2Keycloak.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_kick.rb b/lib/appwrite/models/o_auth2_kick.rb index eb5c8092..1d764fa3 100644 --- a/lib/appwrite/models/o_auth2_kick.rb +++ b/lib/appwrite/models/o_auth2_kick.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Kick.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_linkedin.rb b/lib/appwrite/models/o_auth2_linkedin.rb index 8b91b062..bcac2a97 100644 --- a/lib/appwrite/models/o_auth2_linkedin.rb +++ b/lib/appwrite/models/o_auth2_linkedin.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "primaryClientSecret" => "" }.merge(map) OAuth2Linkedin.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_microsoft.rb b/lib/appwrite/models/o_auth2_microsoft.rb index 29c2cb1e..4525c54c 100644 --- a/lib/appwrite/models/o_auth2_microsoft.rb +++ b/lib/appwrite/models/o_auth2_microsoft.rb @@ -22,11 +22,12 @@ def initialize( @enabled = enabled @application_id = application_id @application_secret = application_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) @tenant = tenant end def self.from(map:) + map = { "$id" => "", "enabled" => false, "applicationId" => "", "applicationSecret" => "", "prompt" => [], "tenant" => "" }.merge(map) OAuth2Microsoft.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_notion.rb b/lib/appwrite/models/o_auth2_notion.rb index 3382c410..1869df5b 100644 --- a/lib/appwrite/models/o_auth2_notion.rb +++ b/lib/appwrite/models/o_auth2_notion.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "oauthClientId" => "", "oauthClientSecret" => "" }.merge(map) OAuth2Notion.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_oidc.rb b/lib/appwrite/models/o_auth2_oidc.rb index a034231b..a3cbee0e 100644 --- a/lib/appwrite/models/o_auth2_oidc.rb +++ b/lib/appwrite/models/o_auth2_oidc.rb @@ -7,11 +7,11 @@ class OAuth2Oidc attr_reader :enabled attr_reader :client_id attr_reader :client_secret + attr_reader :prompt attr_reader :well_known_url attr_reader :authorization_url attr_reader :token_url attr_reader :user_info_url - attr_reader :prompt attr_reader :max_age def initialize( @@ -19,36 +19,37 @@ def initialize( enabled:, client_id:, client_secret:, + prompt:, well_known_url:, authorization_url:, token_url:, user_info_url:, - prompt:, max_age: ) @id = id @enabled = enabled @client_id = client_id @client_secret = client_secret + @prompt = validate_prompt(prompt) @well_known_url = well_known_url @authorization_url = authorization_url @token_url = token_url @user_info_url = user_info_url - @prompt = validate_prompt(prompt) @max_age = max_age end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [], "wellKnownURL" => "", "authorizationURL" => "", "tokenURL" => "", "userInfoURL" => "" }.merge(map) OAuth2Oidc.new( id: map["$id"], enabled: map["enabled"], client_id: map["clientId"], client_secret: map["clientSecret"], + prompt: map["prompt"], well_known_url: map["wellKnownURL"], authorization_url: map["authorizationURL"], token_url: map["tokenURL"], user_info_url: map["userInfoURL"], - prompt: map["prompt"], max_age: map["maxAge"] ) end @@ -59,11 +60,11 @@ def to_map "enabled": @enabled, "clientId": @client_id, "clientSecret": @client_secret, + "prompt": @prompt, "wellKnownURL": @well_known_url, "authorizationURL": @authorization_url, "tokenURL": @token_url, "userInfoURL": @user_info_url, - "prompt": @prompt, "maxAge": @max_age } end diff --git a/lib/appwrite/models/o_auth2_okta.rb b/lib/appwrite/models/o_auth2_okta.rb index 11d5746f..4abfdd09 100644 --- a/lib/appwrite/models/o_auth2_okta.rb +++ b/lib/appwrite/models/o_auth2_okta.rb @@ -24,12 +24,13 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) @domain = domain @authorization_server_id = authorization_server_id end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [], "domain" => "", "authorizationServerId" => "" }.merge(map) OAuth2Okta.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_paypal.rb b/lib/appwrite/models/o_auth2_paypal.rb index 32263b46..27db8cdd 100644 --- a/lib/appwrite/models/o_auth2_paypal.rb +++ b/lib/appwrite/models/o_auth2_paypal.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "secretKey" => "" }.merge(map) OAuth2Paypal.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_podio.rb b/lib/appwrite/models/o_auth2_podio.rb index d1efea82..f25f60e2 100644 --- a/lib/appwrite/models/o_auth2_podio.rb +++ b/lib/appwrite/models/o_auth2_podio.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Podio.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_provider_list.rb b/lib/appwrite/models/o_auth2_provider_list.rb index 16bdbbaf..40596466 100644 --- a/lib/appwrite/models/o_auth2_provider_list.rb +++ b/lib/appwrite/models/o_auth2_provider_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "providers" => [] }.merge(map) OAuth2ProviderList.new( total: map["total"], providers: map["providers"] diff --git a/lib/appwrite/models/o_auth2_resend.rb b/lib/appwrite/models/o_auth2_resend.rb index 9a64087d..86084bde 100644 --- a/lib/appwrite/models/o_auth2_resend.rb +++ b/lib/appwrite/models/o_auth2_resend.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Resend.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_salesforce.rb b/lib/appwrite/models/o_auth2_salesforce.rb index 0cd7bc78..0a3ae31a 100644 --- a/lib/appwrite/models/o_auth2_salesforce.rb +++ b/lib/appwrite/models/o_auth2_salesforce.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @customer_key = customer_key @customer_secret = customer_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "customerKey" => "", "customerSecret" => "", "prompt" => [] }.merge(map) OAuth2Salesforce.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_slack.rb b/lib/appwrite/models/o_auth2_slack.rb index 209cc3b5..149cd400 100644 --- a/lib/appwrite/models/o_auth2_slack.rb +++ b/lib/appwrite/models/o_auth2_slack.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Slack.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_spotify.rb b/lib/appwrite/models/o_auth2_spotify.rb index 014d82dc..addf5467 100644 --- a/lib/appwrite/models/o_auth2_spotify.rb +++ b/lib/appwrite/models/o_auth2_spotify.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Spotify.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_stripe.rb b/lib/appwrite/models/o_auth2_stripe.rb index 66604406..4b580c06 100644 --- a/lib/appwrite/models/o_auth2_stripe.rb +++ b/lib/appwrite/models/o_auth2_stripe.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "apiSecretKey" => "" }.merge(map) OAuth2Stripe.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_tradeshift.rb b/lib/appwrite/models/o_auth2_tradeshift.rb index 749c666d..5099f337 100644 --- a/lib/appwrite/models/o_auth2_tradeshift.rb +++ b/lib/appwrite/models/o_auth2_tradeshift.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "oauth2ClientId" => "", "oauth2ClientSecret" => "" }.merge(map) OAuth2Tradeshift.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_twitch.rb b/lib/appwrite/models/o_auth2_twitch.rb index ac7fa8a1..b2f90f4e 100644 --- a/lib/appwrite/models/o_auth2_twitch.rb +++ b/lib/appwrite/models/o_auth2_twitch.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Twitch.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_word_press.rb b/lib/appwrite/models/o_auth2_word_press.rb index 3fab755c..9453b756 100644 --- a/lib/appwrite/models/o_auth2_word_press.rb +++ b/lib/appwrite/models/o_auth2_word_press.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2WordPress.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_x.rb b/lib/appwrite/models/o_auth2_x.rb index d2f771a4..55b32ea6 100644 --- a/lib/appwrite/models/o_auth2_x.rb +++ b/lib/appwrite/models/o_auth2_x.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "customerKey" => "", "secretKey" => "" }.merge(map) OAuth2X.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_yahoo.rb b/lib/appwrite/models/o_auth2_yahoo.rb index 13aea493..1d0819e1 100644 --- a/lib/appwrite/models/o_auth2_yahoo.rb +++ b/lib/appwrite/models/o_auth2_yahoo.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Yahoo.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_yandex.rb b/lib/appwrite/models/o_auth2_yandex.rb index 8373037e..102e0bf4 100644 --- a/lib/appwrite/models/o_auth2_yandex.rb +++ b/lib/appwrite/models/o_auth2_yandex.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Yandex.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_zoho.rb b/lib/appwrite/models/o_auth2_zoho.rb index 792da041..c7bb5db2 100644 --- a/lib/appwrite/models/o_auth2_zoho.rb +++ b/lib/appwrite/models/o_auth2_zoho.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [] }.merge(map) OAuth2Zoho.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_zoom.rb b/lib/appwrite/models/o_auth2_zoom.rb index d7b261ce..97617c2b 100644 --- a/lib/appwrite/models/o_auth2_zoom.rb +++ b/lib/appwrite/models/o_auth2_zoom.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Zoom.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/oauth2_approve.rb b/lib/appwrite/models/oauth2_approve.rb index 748c7880..32e7f309 100644 --- a/lib/appwrite/models/oauth2_approve.rb +++ b/lib/appwrite/models/oauth2_approve.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "redirectUrl" => "" }.merge(map) Oauth2Approve.new( redirect_url: map["redirectUrl"] ) diff --git a/lib/appwrite/models/oauth2_authorize.rb b/lib/appwrite/models/oauth2_authorize.rb index 99f35e8c..269932a6 100644 --- a/lib/appwrite/models/oauth2_authorize.rb +++ b/lib/appwrite/models/oauth2_authorize.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "grantId" => "", "redirectUrl" => "" }.merge(map) Oauth2Authorize.new( grant_id: map["grantId"], redirect_url: map["redirectUrl"] diff --git a/lib/appwrite/models/oauth2_consent.rb b/lib/appwrite/models/oauth2_consent.rb index af8f3ec0..f1080bca 100644 --- a/lib/appwrite/models/oauth2_consent.rb +++ b/lib/appwrite/models/oauth2_consent.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "appId" => "", "cimdUrl" => "", "scopes" => [], "resources" => [], "authorizationDetails" => "[]", "expire" => "" }.merge(map) Oauth2Consent.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/oauth2_consent_list.rb b/lib/appwrite/models/oauth2_consent_list.rb index a6ca3cea..7543e968 100644 --- a/lib/appwrite/models/oauth2_consent_list.rb +++ b/lib/appwrite/models/oauth2_consent_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "consents" => [] }.merge(map) Oauth2ConsentList.new( total: map["total"], consents: map["consents"].map { |it| Oauth2Consent.from(map: it) } diff --git a/lib/appwrite/models/oauth2_consent_token.rb b/lib/appwrite/models/oauth2_consent_token.rb index 6b1bc02a..bc01ac00 100644 --- a/lib/appwrite/models/oauth2_consent_token.rb +++ b/lib/appwrite/models/oauth2_consent_token.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "consentId" => "", "userId" => "", "appId" => "", "cimdUrl" => "", "scopes" => [], "resources" => [], "authorizationDetails" => "[]", "expire" => "" }.merge(map) Oauth2ConsentToken.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/oauth2_consent_token_list.rb b/lib/appwrite/models/oauth2_consent_token_list.rb index edf5aef9..efcc0a05 100644 --- a/lib/appwrite/models/oauth2_consent_token_list.rb +++ b/lib/appwrite/models/oauth2_consent_token_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "tokens" => [] }.merge(map) Oauth2ConsentTokenList.new( total: map["total"], tokens: map["tokens"].map { |it| Oauth2ConsentToken.from(map: it) } diff --git a/lib/appwrite/models/oauth2_device_authorization.rb b/lib/appwrite/models/oauth2_device_authorization.rb index 428970ac..86c07de1 100644 --- a/lib/appwrite/models/oauth2_device_authorization.rb +++ b/lib/appwrite/models/oauth2_device_authorization.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "device_code" => "", "user_code" => "", "verification_uri" => "", "verification_uri_complete" => "", "expires_in" => 0, "interval" => 0 }.merge(map) Oauth2DeviceAuthorization.new( device_code: map["device_code"], user_code: map["user_code"], diff --git a/lib/appwrite/models/oauth2_grant.rb b/lib/appwrite/models/oauth2_grant.rb index df5192bf..d94b15c5 100644 --- a/lib/appwrite/models/oauth2_grant.rb +++ b/lib/appwrite/models/oauth2_grant.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "appId" => "", "scopes" => [], "resources" => [], "authorizationDetails" => "[]", "prompt" => "", "redirectUri" => "", "authTime" => 0, "expire" => "" }.merge(map) Oauth2Grant.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/oauth2_organization.rb b/lib/appwrite/models/oauth2_organization.rb index b69fd0cb..70916f0e 100644 --- a/lib/appwrite/models/oauth2_organization.rb +++ b/lib/appwrite/models/oauth2_organization.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "" }.merge(map) Oauth2Organization.new( id: map["$id"] ) diff --git a/lib/appwrite/models/oauth2_organization_list.rb b/lib/appwrite/models/oauth2_organization_list.rb index 7921605a..1988d853 100644 --- a/lib/appwrite/models/oauth2_organization_list.rb +++ b/lib/appwrite/models/oauth2_organization_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "organizations" => [] }.merge(map) Oauth2OrganizationList.new( total: map["total"], organizations: map["organizations"].map { |it| Oauth2Organization.from(map: it) } diff --git a/lib/appwrite/models/oauth2_par.rb b/lib/appwrite/models/oauth2_par.rb index 18198dc6..17b3ee44 100644 --- a/lib/appwrite/models/oauth2_par.rb +++ b/lib/appwrite/models/oauth2_par.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "request_uri" => "", "expires_in" => 0 }.merge(map) Oauth2PAR.new( request_uri: map["request_uri"], expires_in: map["expires_in"] diff --git a/lib/appwrite/models/oauth2_project.rb b/lib/appwrite/models/oauth2_project.rb index 01b2531c..437421b6 100644 --- a/lib/appwrite/models/oauth2_project.rb +++ b/lib/appwrite/models/oauth2_project.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "region" => "", "endpoint" => "" }.merge(map) Oauth2Project.new( id: map["$id"], region: map["region"], diff --git a/lib/appwrite/models/oauth2_project_list.rb b/lib/appwrite/models/oauth2_project_list.rb index a98a6769..d6338e3c 100644 --- a/lib/appwrite/models/oauth2_project_list.rb +++ b/lib/appwrite/models/oauth2_project_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "projects" => [] }.merge(map) Oauth2ProjectList.new( total: map["total"], projects: map["projects"].map { |it| Oauth2Project.from(map: it) } diff --git a/lib/appwrite/models/oauth2_reject.rb b/lib/appwrite/models/oauth2_reject.rb index 614546e0..29325140 100644 --- a/lib/appwrite/models/oauth2_reject.rb +++ b/lib/appwrite/models/oauth2_reject.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "redirectUrl" => "" }.merge(map) Oauth2Reject.new( redirect_url: map["redirectUrl"] ) diff --git a/lib/appwrite/models/oauth2_token.rb b/lib/appwrite/models/oauth2_token.rb index 59ffd23f..19511db3 100644 --- a/lib/appwrite/models/oauth2_token.rb +++ b/lib/appwrite/models/oauth2_token.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "access_token" => "", "token_type" => "Bearer", "expires_in" => 0, "refresh_token" => "", "scope" => "" }.merge(map) Oauth2Token.new( access_token: map["access_token"], token_type: map["token_type"], diff --git a/lib/appwrite/models/organization.rb b/lib/appwrite/models/organization.rb index aa53b68a..3ef73281 100644 --- a/lib/appwrite/models/organization.rb +++ b/lib/appwrite/models/organization.rb @@ -114,6 +114,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "total" => 0, "budgetAlerts" => [75], "billingPlan" => "tier-0", "billingPlanId" => "tier-0", "billingEmail" => "", "status" => "draft", "markedForDeletion" => false, "platform" => "appwrite", "projects" => [] }.merge(map) Organization.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/passkey.rb b/lib/appwrite/models/passkey.rb index 5098b87b..8cea8129 100644 --- a/lib/appwrite/models/passkey.rb +++ b/lib/appwrite/models/passkey.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "accessedAt" => "" }.merge(map) Passkey.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/passkey_challenge.rb b/lib/appwrite/models/passkey_challenge.rb index b9751184..22f1774c 100644 --- a/lib/appwrite/models/passkey_challenge.rb +++ b/lib/appwrite/models/passkey_challenge.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "passkeyId" => "", "expire" => "", "publicKey" => {} }.merge(map) PasskeyChallenge.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/passkey_list.rb b/lib/appwrite/models/passkey_list.rb index 86a515b7..dffca579 100644 --- a/lib/appwrite/models/passkey_list.rb +++ b/lib/appwrite/models/passkey_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "passkeys" => [] }.merge(map) PasskeyList.new( total: map["total"], passkeys: map["passkeys"].map { |it| Passkey.from(map: it) } diff --git a/lib/appwrite/models/phone.rb b/lib/appwrite/models/phone.rb index 769ea1be..c4d5137c 100644 --- a/lib/appwrite/models/phone.rb +++ b/lib/appwrite/models/phone.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "code" => "", "countryCode" => "", "countryName" => "" }.merge(map) Phone.new( code: map["code"], country_code: map["countryCode"], diff --git a/lib/appwrite/models/phone_list.rb b/lib/appwrite/models/phone_list.rb index d6ad3e14..fea0fea8 100644 --- a/lib/appwrite/models/phone_list.rb +++ b/lib/appwrite/models/phone_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "phones" => [] }.merge(map) PhoneList.new( total: map["total"], phones: map["phones"].map { |it| Phone.from(map: it) } diff --git a/lib/appwrite/models/platform_android.rb b/lib/appwrite/models/platform_android.rb index da5ba79b..3559270e 100644 --- a/lib/appwrite/models/platform_android.rb +++ b/lib/appwrite/models/platform_android.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "applicationId" => "", "fingerprints" => [] }.merge(map) PlatformAndroid.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_apple.rb b/lib/appwrite/models/platform_apple.rb index 06f7aeea..fa95f584 100644 --- a/lib/appwrite/models/platform_apple.rb +++ b/lib/appwrite/models/platform_apple.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "bundleIdentifier" => "" }.merge(map) PlatformApple.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_linux.rb b/lib/appwrite/models/platform_linux.rb index 1442fd5e..a35bc2ca 100644 --- a/lib/appwrite/models/platform_linux.rb +++ b/lib/appwrite/models/platform_linux.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "packageName" => "" }.merge(map) PlatformLinux.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_list.rb b/lib/appwrite/models/platform_list.rb index a51bb20e..c18d4b33 100644 --- a/lib/appwrite/models/platform_list.rb +++ b/lib/appwrite/models/platform_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "platforms" => [] }.merge(map) PlatformList.new( total: map["total"], platforms: map["platforms"] diff --git a/lib/appwrite/models/platform_web.rb b/lib/appwrite/models/platform_web.rb index 8e84519d..a3925665 100644 --- a/lib/appwrite/models/platform_web.rb +++ b/lib/appwrite/models/platform_web.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "hostname" => "" }.merge(map) PlatformWeb.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_windows.rb b/lib/appwrite/models/platform_windows.rb index 560f44d4..07d1e9d5 100644 --- a/lib/appwrite/models/platform_windows.rb +++ b/lib/appwrite/models/platform_windows.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "packageIdentifierName" => "" }.merge(map) PlatformWindows.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/policy_deny_aliased_email.rb b/lib/appwrite/models/policy_deny_aliased_email.rb index f7b755ae..1a05ce5d 100644 --- a/lib/appwrite/models/policy_deny_aliased_email.rb +++ b/lib/appwrite/models/policy_deny_aliased_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyAliasedEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_deny_corporate_email.rb b/lib/appwrite/models/policy_deny_corporate_email.rb index 4bdf38ae..3680ef40 100644 --- a/lib/appwrite/models/policy_deny_corporate_email.rb +++ b/lib/appwrite/models/policy_deny_corporate_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyCorporateEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_deny_disposable_email.rb b/lib/appwrite/models/policy_deny_disposable_email.rb index 23393bea..f3073750 100644 --- a/lib/appwrite/models/policy_deny_disposable_email.rb +++ b/lib/appwrite/models/policy_deny_disposable_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyDisposableEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_deny_free_email.rb b/lib/appwrite/models/policy_deny_free_email.rb index 766573bb..75bca6f0 100644 --- a/lib/appwrite/models/policy_deny_free_email.rb +++ b/lib/appwrite/models/policy_deny_free_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyFreeEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_list.rb b/lib/appwrite/models/policy_list.rb index 077c62f5..7c5be92c 100644 --- a/lib/appwrite/models/policy_list.rb +++ b/lib/appwrite/models/policy_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "policies" => [] }.merge(map) PolicyList.new( total: map["total"], policies: map["policies"] diff --git a/lib/appwrite/models/policy_membership_privacy.rb b/lib/appwrite/models/policy_membership_privacy.rb index 9fa040f1..2a1a56a4 100644 --- a/lib/appwrite/models/policy_membership_privacy.rb +++ b/lib/appwrite/models/policy_membership_privacy.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "userId" => false, "userEmail" => false, "userPhone" => false, "userName" => false, "userMFA" => false, "userAccessedAt" => false }.merge(map) PolicyMembershipPrivacy.new( id: map["$id"], user_id: map["userId"], diff --git a/lib/appwrite/models/policy_mfa_factors.rb b/lib/appwrite/models/policy_mfa_factors.rb index e49890a8..601ef66d 100644 --- a/lib/appwrite/models/policy_mfa_factors.rb +++ b/lib/appwrite/models/policy_mfa_factors.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "totp" => true, "email" => true, "phone" => true, "custom" => false }.merge(map) PolicyMfaFactors.new( id: map["$id"], totp: map["totp"], diff --git a/lib/appwrite/models/policy_passkey.rb b/lib/appwrite/models/policy_passkey.rb index f9cb6701..62bced03 100644 --- a/lib/appwrite/models/policy_passkey.rb +++ b/lib/appwrite/models/policy_passkey.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "rpId" => "", "origins" => [] }.merge(map) PolicyPasskey.new( id: map["$id"], rp_id: map["rpId"], diff --git a/lib/appwrite/models/policy_password_dictionary.rb b/lib/appwrite/models/policy_password_dictionary.rb index 38423bc4..b72d0caa 100644 --- a/lib/appwrite/models/policy_password_dictionary.rb +++ b/lib/appwrite/models/policy_password_dictionary.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyPasswordDictionary.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_password_history.rb b/lib/appwrite/models/policy_password_history.rb index e2d4b842..f5253d15 100644 --- a/lib/appwrite/models/policy_password_history.rb +++ b/lib/appwrite/models/policy_password_history.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "total" => 0 }.merge(map) PolicyPasswordHistory.new( id: map["$id"], total: map["total"] diff --git a/lib/appwrite/models/policy_password_personal_data.rb b/lib/appwrite/models/policy_password_personal_data.rb index 7e2c290e..2be97bd8 100644 --- a/lib/appwrite/models/policy_password_personal_data.rb +++ b/lib/appwrite/models/policy_password_personal_data.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyPasswordPersonalData.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_password_strength.rb b/lib/appwrite/models/policy_password_strength.rb index c2bf28fb..1240c6a0 100644 --- a/lib/appwrite/models/policy_password_strength.rb +++ b/lib/appwrite/models/policy_password_strength.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "min" => 8, "uppercase" => false, "lowercase" => false, "number" => false, "symbols" => false }.merge(map) PolicyPasswordStrength.new( id: map["$id"], min: map["min"], diff --git a/lib/appwrite/models/policy_session_alert.rb b/lib/appwrite/models/policy_session_alert.rb index 74ee3fa2..7ef6a816 100644 --- a/lib/appwrite/models/policy_session_alert.rb +++ b/lib/appwrite/models/policy_session_alert.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicySessionAlert.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_session_duration.rb b/lib/appwrite/models/policy_session_duration.rb index f23f26e9..2928b255 100644 --- a/lib/appwrite/models/policy_session_duration.rb +++ b/lib/appwrite/models/policy_session_duration.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "duration" => 31536000 }.merge(map) PolicySessionDuration.new( id: map["$id"], duration: map["duration"] diff --git a/lib/appwrite/models/policy_session_invalidation.rb b/lib/appwrite/models/policy_session_invalidation.rb index 4c7b0a2e..6ec72c3b 100644 --- a/lib/appwrite/models/policy_session_invalidation.rb +++ b/lib/appwrite/models/policy_session_invalidation.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => true }.merge(map) PolicySessionInvalidation.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_session_limit.rb b/lib/appwrite/models/policy_session_limit.rb index 2c3783d8..193d81b5 100644 --- a/lib/appwrite/models/policy_session_limit.rb +++ b/lib/appwrite/models/policy_session_limit.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "total" => 0 }.merge(map) PolicySessionLimit.new( id: map["$id"], total: map["total"] diff --git a/lib/appwrite/models/policy_user_limit.rb b/lib/appwrite/models/policy_user_limit.rb index b5554c19..1275753d 100644 --- a/lib/appwrite/models/policy_user_limit.rb +++ b/lib/appwrite/models/policy_user_limit.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "total" => 0 }.merge(map) PolicyUserLimit.new( id: map["$id"], total: map["total"] diff --git a/lib/appwrite/models/postgres_extension.rb b/lib/appwrite/models/postgres_extension.rb index 6ae09339..e1c5f081 100644 --- a/lib/appwrite/models/postgres_extension.rb +++ b/lib/appwrite/models/postgres_extension.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "name" => "", "description" => "", "category" => "" }.merge(map) PostgresExtension.new( key: map["key"], name: map["name"], diff --git a/lib/appwrite/models/presence.rb b/lib/appwrite/models/presence.rb index dabfb838..577da3cc 100644 --- a/lib/appwrite/models/presence.rb +++ b/lib/appwrite/models/presence.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "userId" => "", "source" => "" }.merge(map) Presence.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/presence_list.rb b/lib/appwrite/models/presence_list.rb index 01fa5bcb..b43ba834 100644 --- a/lib/appwrite/models/presence_list.rb +++ b/lib/appwrite/models/presence_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "presences" => [] }.merge(map) PresenceList.new( total: map["total"], presences: map["presences"].map { |it| Presence.from(map: it) } diff --git a/lib/appwrite/models/program.rb b/lib/appwrite/models/program.rb index db9215e1..7705670c 100644 --- a/lib/appwrite/models/program.rb +++ b/lib/appwrite/models/program.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "title" => "", "description" => "", "tag" => "", "icon" => "", "url" => "", "active" => true, "external" => true, "billingPlanId" => "" }.merge(map) Program.new( id: map["$id"], title: map["title"], diff --git a/lib/appwrite/models/project.rb b/lib/appwrite/models/project.rb index b03fcbc6..3af3e1dd 100644 --- a/lib/appwrite/models/project.rb +++ b/lib/appwrite/models/project.rb @@ -9,7 +9,6 @@ class Project attr_reader :name attr_reader :team_id attr_reader :region - attr_reader :dev_keys attr_reader :smtp_enabled attr_reader :smtp_sender_name attr_reader :smtp_sender_email @@ -60,7 +59,6 @@ def initialize( name:, team_id:, region:, - dev_keys:, smtp_enabled:, smtp_sender_name:, smtp_sender_email:, @@ -88,20 +86,20 @@ def initialize( mcp_accessed_at:, o_auth2_server_enabled:, o_auth2_server_authorization_url:, - o_auth2_server_scopes:, - o_auth2_server_default_scopes:, - o_auth2_server_installation_scopes:, - o_auth2_server_authorization_details_types:, - o_auth2_server_access_token_duration:, - 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_scopes: [], + o_auth2_server_default_scopes: [], + o_auth2_server_installation_scopes: [], + o_auth2_server_authorization_details_types: [], + o_auth2_server_access_token_duration: 0, + o_auth2_server_refresh_token_duration: 0, + o_auth2_server_public_access_token_duration: 0, + o_auth2_server_public_refresh_token_duration: 0, + o_auth2_server_installation_access_token_duration: 0, o_auth2_server_confidential_pkce:, o_auth2_server_verification_url:, - o_auth2_server_user_code_length:, - o_auth2_server_user_code_format:, - o_auth2_server_device_code_duration:, + o_auth2_server_user_code_length: 8, + o_auth2_server_user_code_format: "alphanumeric", + o_auth2_server_device_code_duration: 600, o_auth2_server_discovery_url: ) @id = id @@ -110,7 +108,6 @@ def initialize( @name = name @team_id = team_id @region = region - @dev_keys = dev_keys @smtp_enabled = smtp_enabled @smtp_sender_name = smtp_sender_name @smtp_sender_email = smtp_sender_email @@ -156,6 +153,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "teamId" => "", "region" => "fra", "smtpEnabled" => false, "smtpSenderName" => "", "smtpSenderEmail" => "", "smtpReplyToName" => "", "smtpReplyToEmail" => "", "smtpHost" => "", "smtpPort" => 0, "smtpUsername" => "", "smtpPassword" => "", "smtpSecure" => "", "pingCount" => 0, "pingedAt" => "", "labels" => [], "status" => "active", "onboarding" => {}, "authMethods" => [], "services" => [], "protocols" => [], "blocks" => [], "consoleAccessedAt" => "" }.merge(map) Project.new( id: map["$id"], created_at: map["$createdAt"], @@ -163,7 +161,6 @@ def self.from(map:) name: map["name"], team_id: map["teamId"], region: map["region"], - dev_keys: map["devKeys"].map { |it| DevKey.from(map: it) }, smtp_enabled: map["smtpEnabled"], smtp_sender_name: map["smtpSenderName"], smtp_sender_email: map["smtpSenderEmail"], @@ -217,7 +214,6 @@ def to_map "name": @name, "teamId": @team_id, "region": @region, - "devKeys": @dev_keys.map { |it| it.to_map }, "smtpEnabled": @smtp_enabled, "smtpSenderName": @smtp_sender_name, "smtpSenderEmail": @smtp_sender_email, diff --git a/lib/appwrite/models/project_auth_method.rb b/lib/appwrite/models/project_auth_method.rb index 98c67156..23162ba9 100644 --- a/lib/appwrite/models/project_auth_method.rb +++ b/lib/appwrite/models/project_auth_method.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => true }.merge(map) ProjectAuthMethod.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/project_list.rb b/lib/appwrite/models/project_list.rb index 552309a5..f2fd282a 100644 --- a/lib/appwrite/models/project_list.rb +++ b/lib/appwrite/models/project_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "projects" => [] }.merge(map) ProjectList.new( total: map["total"], projects: map["projects"].map { |it| Project.from(map: it) } diff --git a/lib/appwrite/models/project_protocol.rb b/lib/appwrite/models/project_protocol.rb index 58448214..a3071c87 100644 --- a/lib/appwrite/models/project_protocol.rb +++ b/lib/appwrite/models/project_protocol.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => true }.merge(map) ProjectProtocol.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/project_service.rb b/lib/appwrite/models/project_service.rb index 128c31b0..a4ea7343 100644 --- a/lib/appwrite/models/project_service.rb +++ b/lib/appwrite/models/project_service.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => true }.merge(map) ProjectService.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/provider.rb b/lib/appwrite/models/provider.rb index 80d6c956..90a53b7c 100644 --- a/lib/appwrite/models/provider.rb +++ b/lib/appwrite/models/provider.rb @@ -22,7 +22,7 @@ def initialize( enabled:, type:, credentials:, - options: + options: {} ) @id = id @created_at = created_at @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "provider" => "", "enabled" => true, "type" => "", "credentials" => {} }.merge(map) Provider.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/provider_list.rb b/lib/appwrite/models/provider_list.rb index 32f7da98..46909a15 100644 --- a/lib/appwrite/models/provider_list.rb +++ b/lib/appwrite/models/provider_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "providers" => [] }.merge(map) ProviderList.new( total: map["total"], providers: map["providers"].map { |it| Provider.from(map: it) } diff --git a/lib/appwrite/models/proxy_invalidation.rb b/lib/appwrite/models/proxy_invalidation.rb index 584669ac..872f90e6 100644 --- a/lib/appwrite/models/proxy_invalidation.rb +++ b/lib/appwrite/models/proxy_invalidation.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "domain" => "", "type" => "", "reference" => "", "status" => "" }.merge(map) ProxyInvalidation.new( domain: map["domain"], type: map["type"], diff --git a/lib/appwrite/models/proxy_rule.rb b/lib/appwrite/models/proxy_rule.rb index e37a6e6d..b8ac11c1 100644 --- a/lib/appwrite/models/proxy_rule.rb +++ b/lib/appwrite/models/proxy_rule.rb @@ -54,6 +54,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "domain" => "", "type" => "", "trigger" => "", "redirectUrl" => "", "redirectStatusCode" => 301, "deploymentId" => "", "deploymentResourceId" => "", "deploymentVcsProviderBranch" => "", "status" => "unverified", "logs" => "" }.merge(map) ProxyRule.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/proxy_rule_list.rb b/lib/appwrite/models/proxy_rule_list.rb index 24f99239..3f324ae8 100644 --- a/lib/appwrite/models/proxy_rule_list.rb +++ b/lib/appwrite/models/proxy_rule_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "rules" => [] }.merge(map) ProxyRuleList.new( total: map["total"], rules: map["rules"].map { |it| ProxyRule.from(map: it) } diff --git a/lib/appwrite/models/report.rb b/lib/appwrite/models/report.rb index b3912319..e39bde63 100644 --- a/lib/appwrite/models/report.rb +++ b/lib/appwrite/models/report.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "type" => "", "title" => "", "summary" => "", "targetType" => "", "target" => "", "categories" => [], "insights" => [] }.merge(map) Report.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/report_list.rb b/lib/appwrite/models/report_list.rb index 8cdd69a0..40a7cee2 100644 --- a/lib/appwrite/models/report_list.rb +++ b/lib/appwrite/models/report_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "reports" => [] }.merge(map) ReportList.new( total: map["total"], reports: map["reports"].map { |it| Report.from(map: it) } diff --git a/lib/appwrite/models/resource_token.rb b/lib/appwrite/models/resource_token.rb index 61c2b49e..a5d39ace 100644 --- a/lib/appwrite/models/resource_token.rb +++ b/lib/appwrite/models/resource_token.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "resourceId" => "", "resourceType" => "", "expire" => "", "secret" => "", "accessedAt" => "" }.merge(map) ResourceToken.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/resource_token_list.rb b/lib/appwrite/models/resource_token_list.rb index 928b7825..a07536c6 100644 --- a/lib/appwrite/models/resource_token_list.rb +++ b/lib/appwrite/models/resource_token_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "tokens" => [] }.merge(map) ResourceTokenList.new( total: map["total"], tokens: map["tokens"].map { |it| ResourceToken.from(map: it) } diff --git a/lib/appwrite/models/row.rb b/lib/appwrite/models/row.rb index c19c0445..2407b2ca 100644 --- a/lib/appwrite/models/row.rb +++ b/lib/appwrite/models/row.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$sequence" => "", "$tableId" => "", "$databaseId" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [] }.merge(map) Row.new( id: map["$id"], sequence: map["$sequence"], diff --git a/lib/appwrite/models/row_list.rb b/lib/appwrite/models/row_list.rb index debd9e50..55bcab78 100644 --- a/lib/appwrite/models/row_list.rb +++ b/lib/appwrite/models/row_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "rows" => [] }.merge(map) RowList.new( total: map["total"], rows: map["rows"].map { |it| Row.from(map: it) } diff --git a/lib/appwrite/models/runtime.rb b/lib/appwrite/models/runtime.rb index 4a09aa27..840663d4 100644 --- a/lib/appwrite/models/runtime.rb +++ b/lib/appwrite/models/runtime.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "key" => "", "name" => "", "version" => "", "base" => "", "image" => "", "logo" => "", "supports" => [] }.merge(map) Runtime.new( id: map["$id"], key: map["key"], diff --git a/lib/appwrite/models/runtime_list.rb b/lib/appwrite/models/runtime_list.rb index 5b69b4a6..018a5bf6 100644 --- a/lib/appwrite/models/runtime_list.rb +++ b/lib/appwrite/models/runtime_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "runtimes" => [] }.merge(map) RuntimeList.new( total: map["total"], runtimes: map["runtimes"].map { |it| Runtime.from(map: it) } diff --git a/lib/appwrite/models/session.rb b/lib/appwrite/models/session.rb index 762ee427..0777f369 100644 --- a/lib/appwrite/models/session.rb +++ b/lib/appwrite/models/session.rb @@ -96,6 +96,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "expire" => "", "provider" => "", "providerUid" => "", "providerAccessToken" => "", "providerAccessTokenExpiry" => "", "providerRefreshToken" => "", "ip" => "", "osCode" => "", "osName" => "", "osVersion" => "", "clientType" => "", "clientCode" => "", "clientName" => "", "clientVersion" => "", "clientEngine" => "", "clientEngineVersion" => "", "deviceName" => "", "deviceBrand" => "", "deviceModel" => "", "countryCode" => "", "countryName" => "", "current" => false, "factors" => [], "secret" => "", "mfaUpdatedAt" => "" }.merge(map) Session.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/session_list.rb b/lib/appwrite/models/session_list.rb index 320cefec..b55a7b94 100644 --- a/lib/appwrite/models/session_list.rb +++ b/lib/appwrite/models/session_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "sessions" => [] }.merge(map) SessionList.new( total: map["total"], sessions: map["sessions"].map { |it| Session.from(map: it) } diff --git a/lib/appwrite/models/site.rb b/lib/appwrite/models/site.rb index 94e80f00..60300827 100644 --- a/lib/appwrite/models/site.rb +++ b/lib/appwrite/models/site.rb @@ -114,6 +114,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "enabled" => true, "live" => true, "logging" => true, "framework" => "", "deploymentRetention" => 0, "deploymentId" => "", "deploymentCreatedAt" => "", "deploymentScreenshotLight" => "", "deploymentScreenshotDark" => "", "latestDeploymentId" => "", "latestDeploymentCreatedAt" => "", "latestDeploymentStatus" => "", "scopes" => [], "vars" => [], "timeout" => 15, "installCommand" => "", "buildCommand" => "", "startCommand" => "", "outputDirectory" => "", "installationId" => "", "providerRepositoryId" => "", "providerBranch" => "", "providerRootDirectory" => "", "providerSilentMode" => false, "providerBranches" => [], "providerPaths" => [], "buildSpecification" => "s-1vcpu-512mb", "runtimeSpecification" => "s-1vcpu-512mb", "buildRuntime" => "" }.merge(map) Site.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/site_list.rb b/lib/appwrite/models/site_list.rb index 51fb319d..f9537cc7 100644 --- a/lib/appwrite/models/site_list.rb +++ b/lib/appwrite/models/site_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "sites" => [] }.merge(map) SiteList.new( total: map["total"], sites: map["sites"].map { |it| Site.from(map: it) } diff --git a/lib/appwrite/models/specification.rb b/lib/appwrite/models/specification.rb index e9ff5467..b8606f25 100644 --- a/lib/appwrite/models/specification.rb +++ b/lib/appwrite/models/specification.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "memory" => 0, "cpus" => 0, "enabled" => false, "slug" => "" }.merge(map) Specification.new( memory: map["memory"], cpus: map["cpus"], diff --git a/lib/appwrite/models/specification_list.rb b/lib/appwrite/models/specification_list.rb index 8212053d..f79e4e31 100644 --- a/lib/appwrite/models/specification_list.rb +++ b/lib/appwrite/models/specification_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "specifications" => [] }.merge(map) SpecificationList.new( total: map["total"], specifications: map["specifications"].map { |it| Specification.from(map: it) } diff --git a/lib/appwrite/models/subscriber.rb b/lib/appwrite/models/subscriber.rb index 318baaab..b2e07da3 100644 --- a/lib/appwrite/models/subscriber.rb +++ b/lib/appwrite/models/subscriber.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "targetId" => "", "userId" => "", "userName" => "", "topicId" => "", "providerType" => "" }.merge(map) Subscriber.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/subscriber_list.rb b/lib/appwrite/models/subscriber_list.rb index 01373385..904bf7d0 100644 --- a/lib/appwrite/models/subscriber_list.rb +++ b/lib/appwrite/models/subscriber_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "subscribers" => [] }.merge(map) SubscriberList.new( total: map["total"], subscribers: map["subscribers"].map { |it| Subscriber.from(map: it) } diff --git a/lib/appwrite/models/table.rb b/lib/appwrite/models/table.rb index 2a7e4649..69851a39 100644 --- a/lib/appwrite/models/table.rb +++ b/lib/appwrite/models/table.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "databaseId" => "", "name" => "", "enabled" => true, "rowSecurity" => false, "columns" => [], "indexes" => [], "bytesMax" => 0, "bytesUsed" => 0 }.merge(map) Table.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/table_list.rb b/lib/appwrite/models/table_list.rb index 034d7fb3..98d96311 100644 --- a/lib/appwrite/models/table_list.rb +++ b/lib/appwrite/models/table_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "tables" => [] }.merge(map) TableList.new( total: map["total"], tables: map["tables"].map { |it| Table.from(map: it) } diff --git a/lib/appwrite/models/target.rb b/lib/appwrite/models/target.rb index 56e90755..8d11a1fe 100644 --- a/lib/appwrite/models/target.rb +++ b/lib/appwrite/models/target.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "userId" => "", "providerType" => "", "identifier" => "", "expired" => false }.merge(map) Target.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/target_list.rb b/lib/appwrite/models/target_list.rb index 9ccd7705..1c7fe0e8 100644 --- a/lib/appwrite/models/target_list.rb +++ b/lib/appwrite/models/target_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "targets" => [] }.merge(map) TargetList.new( total: map["total"], targets: map["targets"].map { |it| Target.from(map: it) } diff --git a/lib/appwrite/models/team.rb b/lib/appwrite/models/team.rb index d08f183f..06bcaf72 100644 --- a/lib/appwrite/models/team.rb +++ b/lib/appwrite/models/team.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "total" => 0 }.merge(map) Team.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/team_list.rb b/lib/appwrite/models/team_list.rb index e02efc9c..01300672 100644 --- a/lib/appwrite/models/team_list.rb +++ b/lib/appwrite/models/team_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "teams" => [] }.merge(map) TeamList.new( total: map["total"], teams: map["teams"].map { |it| Team.from(map: it) } diff --git a/lib/appwrite/models/token.rb b/lib/appwrite/models/token.rb index b3f539af..bf6c51a9 100644 --- a/lib/appwrite/models/token.rb +++ b/lib/appwrite/models/token.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "secret" => "", "expire" => "", "phrase" => "" }.merge(map) Token.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/token_secret.rb b/lib/appwrite/models/token_secret.rb index 4744532f..31ef131b 100644 --- a/lib/appwrite/models/token_secret.rb +++ b/lib/appwrite/models/token_secret.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "secret" => "", "expire" => "", "phrase" => "" }.merge(map) TokenSecret.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/topic.rb b/lib/appwrite/models/topic.rb index 247284d8..9f7c6a6c 100644 --- a/lib/appwrite/models/topic.rb +++ b/lib/appwrite/models/topic.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "emailTotal" => 0, "smsTotal" => 0, "pushTotal" => 0, "subscribe" => ["users"] }.merge(map) Topic.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/topic_list.rb b/lib/appwrite/models/topic_list.rb index e1b8c6d0..9542c588 100644 --- a/lib/appwrite/models/topic_list.rb +++ b/lib/appwrite/models/topic_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "topics" => [] }.merge(map) TopicList.new( total: map["total"], topics: map["topics"].map { |it| Topic.from(map: it) } diff --git a/lib/appwrite/models/transaction.rb b/lib/appwrite/models/transaction.rb index 481c25c9..e35a80fa 100644 --- a/lib/appwrite/models/transaction.rb +++ b/lib/appwrite/models/transaction.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "status" => "pending", "operations" => 0, "expiresAt" => "" }.merge(map) Transaction.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/transaction_list.rb b/lib/appwrite/models/transaction_list.rb index 17234abd..0db83c65 100644 --- a/lib/appwrite/models/transaction_list.rb +++ b/lib/appwrite/models/transaction_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "transactions" => [] }.merge(map) TransactionList.new( total: map["total"], transactions: map["transactions"].map { |it| Transaction.from(map: it) } diff --git a/lib/appwrite/models/usage_billing_plan.rb b/lib/appwrite/models/usage_billing_plan.rb index be1d81f6..0a181abb 100644 --- a/lib/appwrite/models/usage_billing_plan.rb +++ b/lib/appwrite/models/usage_billing_plan.rb @@ -43,32 +43,32 @@ def initialize( def self.from(map:) UsageBillingPlan.new( - bandwidth: AdditionalResource.from(map: map["bandwidth"]), - executions: AdditionalResource.from(map: map["executions"]), + bandwidth: map["bandwidth"].nil? ? nil : AdditionalResource.from(map: map["bandwidth"]), + executions: map["executions"].nil? ? nil : AdditionalResource.from(map: map["executions"]), member: map["member"].nil? ? nil : AdditionalResource.from(map: map["member"]), - realtime: AdditionalResource.from(map: map["realtime"]), - realtime_messages: AdditionalResource.from(map: map["realtimeMessages"]), + realtime: map["realtime"].nil? ? nil : AdditionalResource.from(map: map["realtime"]), + realtime_messages: map["realtimeMessages"].nil? ? nil : AdditionalResource.from(map: map["realtimeMessages"]), realtime_bandwidth: map["realtimeBandwidth"].nil? ? nil : AdditionalResource.from(map: map["realtimeBandwidth"]), - storage: AdditionalResource.from(map: map["storage"]), - users: AdditionalResource.from(map: map["users"]), - gb_hours: AdditionalResource.from(map: map["GBHours"]), - image_transformations: AdditionalResource.from(map: map["imageTransformations"]), + storage: map["storage"].nil? ? nil : AdditionalResource.from(map: map["storage"]), + users: map["users"].nil? ? nil : AdditionalResource.from(map: map["users"]), + gb_hours: map["GBHours"].nil? ? nil : AdditionalResource.from(map: map["GBHours"]), + image_transformations: map["imageTransformations"].nil? ? nil : AdditionalResource.from(map: map["imageTransformations"]), credits: map["credits"].nil? ? nil : AdditionalResource.from(map: map["credits"]) ) end def to_map { - "bandwidth": @bandwidth.to_map, - "executions": @executions.to_map, + "bandwidth": @bandwidth&.to_map, + "executions": @executions&.to_map, "member": @member&.to_map, - "realtime": @realtime.to_map, - "realtimeMessages": @realtime_messages.to_map, + "realtime": @realtime&.to_map, + "realtimeMessages": @realtime_messages&.to_map, "realtimeBandwidth": @realtime_bandwidth&.to_map, - "storage": @storage.to_map, - "users": @users.to_map, - "GBHours": @gb_hours.to_map, - "imageTransformations": @image_transformations.to_map, + "storage": @storage&.to_map, + "users": @users&.to_map, + "GBHours": @gb_hours&.to_map, + "imageTransformations": @image_transformations&.to_map, "credits": @credits&.to_map } end diff --git a/lib/appwrite/models/user.rb b/lib/appwrite/models/user.rb index 9586ee8c..240a4f11 100644 --- a/lib/appwrite/models/user.rb +++ b/lib/appwrite/models/user.rb @@ -90,6 +90,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "registration" => "", "status" => true, "labels" => [], "passwordUpdate" => "", "email" => "", "phone" => "", "emailVerification" => false, "phoneVerification" => false, "mfa" => false, "targets" => [], "accessedAt" => "" }.merge(map) User.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/user_list.rb b/lib/appwrite/models/user_list.rb index 79c4c6d3..62660196 100644 --- a/lib/appwrite/models/user_list.rb +++ b/lib/appwrite/models/user_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "users" => [] }.merge(map) UserList.new( total: map["total"], users: map["users"].map { |it| User.from(map: it) } diff --git a/lib/appwrite/models/variable.rb b/lib/appwrite/models/variable.rb index 1c14a73d..d5722127 100644 --- a/lib/appwrite/models/variable.rb +++ b/lib/appwrite/models/variable.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "key" => "", "value" => "", "secret" => false, "resourceType" => "", "resourceId" => "" }.merge(map) Variable.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/variable_list.rb b/lib/appwrite/models/variable_list.rb index 6c36b9d1..bfe9230f 100644 --- a/lib/appwrite/models/variable_list.rb +++ b/lib/appwrite/models/variable_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "variables" => [] }.merge(map) VariableList.new( total: map["total"], variables: map["variables"].map { |it| Variable.from(map: it) } diff --git a/lib/appwrite/models/vectorsdb_collection.rb b/lib/appwrite/models/vectorsdb_collection.rb index fc878665..0f3842c3 100644 --- a/lib/appwrite/models/vectorsdb_collection.rb +++ b/lib/appwrite/models/vectorsdb_collection.rb @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "databaseId" => "", "name" => "", "enabled" => true, "documentSecurity" => false, "attributes" => [], "indexes" => [], "bytesMax" => 0, "bytesUsed" => 0, "dimension" => 0 }.merge(map) VectorsdbCollection.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/vectorsdb_collection_list.rb b/lib/appwrite/models/vectorsdb_collection_list.rb index e933696b..e38a9a4d 100644 --- a/lib/appwrite/models/vectorsdb_collection_list.rb +++ b/lib/appwrite/models/vectorsdb_collection_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "collections" => [] }.merge(map) VectorsdbCollectionList.new( total: map["total"], collections: map["collections"].map { |it| VectorsdbCollection.from(map: it) } diff --git a/lib/appwrite/models/webhook.rb b/lib/appwrite/models/webhook.rb index 5e418078..333fc55b 100644 --- a/lib/appwrite/models/webhook.rb +++ b/lib/appwrite/models/webhook.rb @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "url" => "", "events" => [], "tls" => true, "authUsername" => "", "authPassword" => "", "secret" => "", "enabled" => true, "logs" => "", "attempts" => 0 }.merge(map) Webhook.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/webhook_list.rb b/lib/appwrite/models/webhook_list.rb index 1df070b9..ee1af6f5 100644 --- a/lib/appwrite/models/webhook_list.rb +++ b/lib/appwrite/models/webhook_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "webhooks" => [] }.merge(map) WebhookList.new( total: map["total"], webhooks: map["webhooks"].map { |it| Webhook.from(map: it) } diff --git a/lib/appwrite/services/account.rb b/lib/appwrite/services/account.rb index 837b7cb8..2e21f2a1 100644 --- a/lib/appwrite/services/account.rb +++ b/lib/appwrite/services/account.rb @@ -49,8 +49,6 @@ def create( password:, name: nil ) - api_path = '/account' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -63,6 +61,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account' + api_params = { userId: user_id, email: email, @@ -126,13 +126,13 @@ def list_consents( def get_consent( consent_id: ) - api_path = '/account/consents/{consentId}' - .gsub('{consentId}', consent_id) - - if consent_id.nil? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end + api_path = '/account/consents/{consentId}' + .gsub('{consentId}', consent_id) + api_params = {} api_headers = { @@ -159,13 +159,13 @@ def get_consent( def delete_consent( consent_id: ) - api_path = '/account/consents/{consentId}' - .gsub('{consentId}', consent_id) - - if consent_id.nil? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end + api_path = '/account/consents/{consentId}' + .gsub('{consentId}', consent_id) + api_params = {} api_headers = { @@ -196,13 +196,13 @@ def list_consent_tokens( queries: nil, total: nil ) - api_path = '/account/consents/{consentId}/tokens' - .gsub('{consentId}', consent_id) - - if consent_id.nil? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end + api_path = '/account/consents/{consentId}/tokens' + .gsub('{consentId}', consent_id) + api_params = { queries: queries, total: total, @@ -233,18 +233,18 @@ 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? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/account/consents/{consentId}/tokens/{tokenId}' + .gsub('{consentId}', consent_id) + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { @@ -273,18 +273,18 @@ 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? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/account/consents/{consentId}/tokens/{tokenId}' + .gsub('{consentId}', consent_id) + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { @@ -318,8 +318,6 @@ def update_email( email:, password: ) - api_path = '/account/email' - if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end @@ -328,6 +326,8 @@ def update_email( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/email' + api_params = { email: email, password: password, @@ -387,57 +387,26 @@ def list_identities( def delete_identity( identity_id: ) - api_path = '/account/identities/{identityId}' - .gsub('{identityId}', identity_id) - - if identity_id.nil? + if identity_id.nil? || identity_id == '' raise Appwrite::Exception.new('Missing required parameter: "identityId"') end + api_path = '/account/identities/{identityId}' + .gsub('{identityId}', identity_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', - } - - @client.call( - method: 'DELETE', - path: api_path, - headers: api_headers, - params: api_params, - ) - end - - # Get the list of latest security activity logs for the currently logged in - # user. Each log returns user IP address, location and date and time of log. - # - # @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). Only supported methods are limit and offset - # @param [] total When set to false, the total count returned will be 0 and will not be calculated. - # - # @return [LogList] - def list_logs( - queries: nil, - total: nil - ) - api_path = '/account/logs' - - api_params = { - queries: queries, - total: total, - } - - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( - method: 'GET', + method: 'DELETE', path: api_path, headers: api_headers, params: api_params, - response_type: Models::LogList ) end @@ -449,12 +418,12 @@ def list_logs( def update_mfa( mfa: ) - api_path = '/account/mfa' - if mfa.nil? raise Appwrite::Exception.new('Missing required parameter: "mfa"') end + api_path = '/account/mfa' + api_params = { mfa: mfa, } @@ -485,13 +454,13 @@ def update_mfa( def create_mfa_authenticator( type: ) - api_path = '/account/mfa/authenticators/{type}' - .gsub('{type}', type) - if type.nil? raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/account/mfa/authenticators/{type}' + .gsub('{type}', type) + api_params = {} api_headers = { @@ -521,9 +490,6 @@ def update_mfa_authenticator( type:, otp: ) - api_path = '/account/mfa/authenticators/{type}' - .gsub('{type}', type) - if type.nil? raise Appwrite::Exception.new('Missing required parameter: "type"') end @@ -532,6 +498,9 @@ def update_mfa_authenticator( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/account/mfa/authenticators/{type}' + .gsub('{type}', type) + api_params = { otp: otp, } @@ -559,18 +528,19 @@ def update_mfa_authenticator( def delete_mfa_authenticator( type: ) - api_path = '/account/mfa/authenticators/{type}' - .gsub('{type}', type) - if type.nil? raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/account/mfa/authenticators/{type}' + .gsub('{type}', type) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -591,12 +561,12 @@ def delete_mfa_authenticator( def create_mfa_challenge( factor: ) - api_path = '/account/mfa/challenges' - if factor.nil? raise Appwrite::Exception.new('Missing required parameter: "factor"') end + api_path = '/account/mfa/challenges' + api_params = { factor: factor, } @@ -630,8 +600,6 @@ def update_mfa_challenge( challenge_id:, otp: ) - api_path = '/account/mfa/challenges' - if challenge_id.nil? raise Appwrite::Exception.new('Missing required parameter: "challengeId"') end @@ -640,6 +608,8 @@ def update_mfa_challenge( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/account/mfa/challenges' + api_params = { challengeId: challenge_id, otp: otp, @@ -772,12 +742,12 @@ def update_mfa_recovery_codes() def update_name( name: ) - api_path = '/account/name' - if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/account/name' + api_params = { name: name, } @@ -1029,12 +999,12 @@ def update_password( password:, old_password: nil ) - api_path = '/account/password' - if password.nil? raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/password' + api_params = { password: password, oldPassword: old_password, @@ -1069,8 +1039,6 @@ def update_phone( phone:, password: ) - api_path = '/account/phone' - if phone.nil? raise Appwrite::Exception.new('Missing required parameter: "phone"') end @@ -1079,6 +1047,8 @@ def update_phone( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/phone' + api_params = { phone: phone, password: password, @@ -1132,12 +1102,12 @@ def get_prefs() def update_prefs( prefs: ) - api_path = '/account/prefs' - if prefs.nil? raise Appwrite::Exception.new('Missing required parameter: "prefs"') end + api_path = '/account/prefs' + api_params = { prefs: prefs, } @@ -1174,8 +1144,6 @@ def create_recovery( email:, url: ) - api_path = '/account/recovery' - if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end @@ -1184,6 +1152,8 @@ def create_recovery( raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/account/recovery' + api_params = { email: email, url: url, @@ -1225,8 +1195,6 @@ def update_recovery( secret:, password: ) - api_path = '/account/recovery' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1239,6 +1207,8 @@ def update_recovery( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/recovery' + api_params = { userId: user_id, secret: secret, @@ -1392,7 +1362,8 @@ def list_sessions( end # Delete all sessions from the user account and remove any sessions cookies - # from the end client. + # from the end client. Pass `current` as false to keep the session making the + # request and sign out of every other session. # # @param [] current Delete the current session too. Use false to sign out of every other session while staying signed in on this one. # @@ -1409,6 +1380,7 @@ def delete_sessions( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1451,6 +1423,9 @@ def create_anonymous_session() # Allow the user to login into their account by providing a valid email and # password combination. This route will create a new session for the user. + # Use the optional `duration` parameter to create a shorter session, for + # example when the user doesn't choose "remember me". It must be at least 60 + # seconds and cannot exceed the project maximum session length. # # A user is limited to 10 active sessions at a time by default. [Learn more # about session @@ -1466,8 +1441,6 @@ def create_email_password_session( password:, duration: nil ) - api_path = '/account/sessions/email' - if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end @@ -1476,6 +1449,8 @@ def create_email_password_session( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/sessions/email' + api_params = { email: email, password: password, @@ -1605,8 +1580,6 @@ def update_magic_url_session( user_id:, secret: ) - api_path = '/account/sessions/magic-url' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1615,6 +1588,8 @@ def update_magic_url_session( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/sessions/magic-url' + api_params = { userId: user_id, secret: secret, @@ -1650,8 +1625,6 @@ def update_phone_session( user_id:, secret: ) - api_path = '/account/sessions/phone' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1660,6 +1633,8 @@ def update_phone_session( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/sessions/phone' + api_params = { userId: user_id, secret: secret, @@ -1692,8 +1667,6 @@ def create_session( user_id:, secret: ) - api_path = '/account/sessions/token' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1702,6 +1675,8 @@ def create_session( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/sessions/token' + api_params = { userId: user_id, secret: secret, @@ -1731,13 +1706,13 @@ def create_session( def get_session( session_id: ) - api_path = '/account/sessions/{sessionId}' - .gsub('{sessionId}', session_id) - - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/account/sessions/{sessionId}' + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { @@ -1764,13 +1739,13 @@ def get_session( def update_session( session_id: ) - api_path = '/account/sessions/{sessionId}' - .gsub('{sessionId}', session_id) - - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/account/sessions/{sessionId}' + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { @@ -1800,18 +1775,19 @@ def update_session( def delete_session( session_id: ) - api_path = '/account/sessions/{sessionId}' - .gsub('{sessionId}', session_id) - - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/account/sessions/{sessionId}' + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1873,8 +1849,6 @@ def create_email_token( email:, phrase: nil ) - api_path = '/account/tokens/email' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1883,6 +1857,8 @@ def create_email_token( raise Appwrite::Exception.new('Missing required parameter: "email"') end + api_path = '/account/tokens/email' + api_params = { userId: user_id, email: email, @@ -1931,8 +1907,6 @@ def create_magic_url_token( url: nil, phrase: nil ) - api_path = '/account/tokens/magic-url' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1941,6 +1915,8 @@ def create_magic_url_token( raise Appwrite::Exception.new('Missing required parameter: "email"') end + api_path = '/account/tokens/magic-url' + api_params = { userId: user_id, email: email, @@ -1974,11 +1950,15 @@ def create_magic_url_token( # session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) # endpoint. # + # If there is already an active session, the OAuth2 identity is attached to + # the logged-in account and that session stays active until the token is + # exchanged for a new one. + # # A user is limited to 10 active sessions at a time by default. [Learn more # about session # limits](https://appwrite.io/docs/authentication-security#limits). # - # @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + # @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom. # @param [String] success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. # @param [String] failure URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. # @param [Array] scopes A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. @@ -1992,13 +1972,13 @@ def create_o_auth2_token( scopes: nil, state: nil ) - api_path = '/account/tokens/oauth2/{provider}' - .gsub('{provider}', provider) - if provider.nil? raise Appwrite::Exception.new('Missing required parameter: "provider"') end + api_path = '/account/tokens/oauth2/{provider}' + .gsub('{provider}', provider) + api_params = { success: success, failure: failure, @@ -2117,8 +2097,6 @@ def create_phone_token( user_id:, phone: ) - api_path = '/account/tokens/phone' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2127,6 +2105,8 @@ def create_phone_token( raise Appwrite::Exception.new('Missing required parameter: "phone"') end + api_path = '/account/tokens/phone' + api_params = { userId: user_id, phone: phone, @@ -2169,12 +2149,12 @@ def create_phone_token( def create_email_verification( url: ) - api_path = '/account/verifications/email' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/account/verifications/email' + api_params = { url: url, } @@ -2219,12 +2199,12 @@ def create_email_verification( def create_verification( url: ) - api_path = '/account/verifications/email' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/account/verifications/email' + api_params = { url: url, } @@ -2257,8 +2237,6 @@ def update_email_verification( user_id:, secret: ) - api_path = '/account/verifications/email' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2267,6 +2245,8 @@ def update_email_verification( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/verifications/email' + api_params = { userId: user_id, secret: secret, @@ -2303,8 +2283,6 @@ def update_verification( user_id:, secret: ) - api_path = '/account/verifications/email' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2313,6 +2291,8 @@ def update_verification( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/verifications/email' + api_params = { userId: user_id, secret: secret, @@ -2465,8 +2445,6 @@ def update_phone_verification( user_id:, secret: ) - api_path = '/account/verifications/phone' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2475,6 +2453,8 @@ def update_phone_verification( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/verifications/phone' + api_params = { userId: user_id, secret: secret, diff --git a/lib/appwrite/services/activities.rb b/lib/appwrite/services/activities.rb index 2c4c457f..e6030e18 100644 --- a/lib/appwrite/services/activities.rb +++ b/lib/appwrite/services/activities.rb @@ -43,13 +43,13 @@ def list_events( def get_event( event_id: ) - api_path = '/activities/events/{eventId}' - .gsub('{eventId}', event_id) - - if event_id.nil? + if event_id.nil? || event_id == '' raise Appwrite::Exception.new('Missing required parameter: "eventId"') end + api_path = '/activities/events/{eventId}' + .gsub('{eventId}', event_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/advisor.rb b/lib/appwrite/services/advisor.rb index 7efe9fa7..180fb950 100644 --- a/lib/appwrite/services/advisor.rb +++ b/lib/appwrite/services/advisor.rb @@ -49,13 +49,13 @@ def list_reports( def get_report( report_id: ) - api_path = '/reports/{reportId}' - .gsub('{reportId}', report_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end + api_path = '/reports/{reportId}' + .gsub('{reportId}', report_id) + api_params = {} api_headers = { @@ -82,18 +82,19 @@ def get_report( def delete_report( report_id: ) - api_path = '/reports/{reportId}' - .gsub('{reportId}', report_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end + api_path = '/reports/{reportId}' + .gsub('{reportId}', report_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -118,13 +119,13 @@ def list_insights( queries: nil, total: nil ) - api_path = '/reports/{reportId}/insights' - .gsub('{reportId}', report_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end + api_path = '/reports/{reportId}/insights' + .gsub('{reportId}', report_id) + api_params = { queries: queries, total: total, @@ -155,18 +156,18 @@ def get_insight( report_id:, insight_id: ) - api_path = '/reports/{reportId}/insights/{insightId}' - .gsub('{reportId}', report_id) - .gsub('{insightId}', insight_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end - if insight_id.nil? + if insight_id.nil? || insight_id == '' raise Appwrite::Exception.new('Missing required parameter: "insightId"') end + api_path = '/reports/{reportId}/insights/{insightId}' + .gsub('{reportId}', report_id) + .gsub('{insightId}', insight_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/apps.rb b/lib/appwrite/services/apps.rb index c4c15c1f..ceeb7dca 100644 --- a/lib/appwrite/services/apps.rb +++ b/lib/appwrite/services/apps.rb @@ -81,8 +81,6 @@ def create( device_flow: nil, team_id: nil ) - api_path = '/apps' - if app_id.nil? raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -95,6 +93,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "redirectUris"') end + api_path = '/apps' + api_params = { appId: app_id, name: name, @@ -186,13 +186,13 @@ def list_o_auth2_scopes() def get( app_id: ) - api_path = '/apps/{appId}' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -255,10 +255,7 @@ def update( installation_scopes: nil, installation_redirect_url: nil ) - api_path = '/apps/{appId}' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -266,6 +263,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/apps/{appId}' + .gsub('{appId}', app_id) + api_params = { name: name, description: description, @@ -311,13 +311,13 @@ def update( def delete( app_id: ) - api_path = '/apps/{appId}' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -348,13 +348,13 @@ def list_installations( queries: nil, total: nil ) - api_path = '/apps/{appId}/installations' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/installations' + .gsub('{appId}', app_id) + api_params = { queries: queries, total: total, @@ -386,18 +386,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/apps/{appId}/installations/{installationId}' + .gsub('{appId}', app_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -426,18 +426,18 @@ def delete_installation( app_id:, installation_id: ) - api_path = '/apps/{appId}/installations/{installationId}' - .gsub('{appId}', app_id) - .gsub('{installationId}', installation_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/apps/{appId}/installations/{installationId}' + .gsub('{appId}', app_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -471,18 +471,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/apps/{appId}/installations/{installationId}/tokens' + .gsub('{appId}', app_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -512,13 +512,13 @@ def list_keys( queries: nil, total: nil ) - api_path = '/apps/{appId}/keys' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/keys' + .gsub('{appId}', app_id) + api_params = { queries: queries, total: total, @@ -548,13 +548,13 @@ def list_keys( def create_key( app_id: ) - api_path = '/apps/{appId}/keys' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/keys' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -582,18 +582,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/apps/{appId}/keys/{keyId}' + .gsub('{appId}', app_id) + .gsub('{keyId}', key_id) + api_params = {} api_headers = { @@ -620,18 +620,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/apps/{appId}/keys/{keyId}' + .gsub('{appId}', app_id) + .gsub('{keyId}', key_id) + api_params = {} api_headers = { @@ -653,17 +653,14 @@ def delete_key( # 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. + # @param [Array] labels Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. Reserved labels are rejected. # # @return [App] def update_labels( app_id:, labels: ) - api_path = '/apps/{appId}/labels' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -671,6 +668,9 @@ def update_labels( raise Appwrite::Exception.new('Missing required parameter: "labels"') end + api_path = '/apps/{appId}/labels' + .gsub('{appId}', app_id) + api_params = { labels: labels, } @@ -702,13 +702,13 @@ def list_secrets( queries: nil, total: nil ) - api_path = '/apps/{appId}/secrets' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/secrets' + .gsub('{appId}', app_id) + api_params = { queries: queries, total: total, @@ -736,13 +736,13 @@ def list_secrets( def create_secret( app_id: ) - api_path = '/apps/{appId}/secrets' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/secrets' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -770,18 +770,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if secret_id.nil? + if secret_id.nil? || secret_id == '' raise Appwrite::Exception.new('Missing required parameter: "secretId"') end + api_path = '/apps/{appId}/secrets/{secretId}' + .gsub('{appId}', app_id) + .gsub('{secretId}', secret_id) + api_params = {} api_headers = { @@ -808,18 +808,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if secret_id.nil? + if secret_id.nil? || secret_id == '' raise Appwrite::Exception.new('Missing required parameter: "secretId"') end + api_path = '/apps/{appId}/secrets/{secretId}' + .gsub('{appId}', app_id) + .gsub('{secretId}', secret_id) + api_params = {} api_headers = { @@ -846,10 +846,7 @@ def update_team( app_id:, team_id: ) - api_path = '/apps/{appId}/team' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -857,6 +854,9 @@ def update_team( raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/apps/{appId}/team' + .gsub('{appId}', app_id) + api_params = { teamId: team_id, } @@ -884,13 +884,13 @@ def update_team( def delete_tokens( app_id: ) - api_path = '/apps/{appId}/tokens' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/tokens' + .gsub('{appId}', app_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/avatars.rb b/lib/appwrite/services/avatars.rb index d3ab6a03..1555c4f2 100644 --- a/lib/appwrite/services/avatars.rb +++ b/lib/appwrite/services/avatars.rb @@ -29,13 +29,13 @@ def get_browser( height: nil, quality: nil ) - api_path = '/avatars/browsers/{code}' - .gsub('{code}', code) - if code.nil? raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/avatars/browsers/{code}' + .gsub('{code}', code) + api_params = { width: width, height: height, @@ -77,13 +77,13 @@ def get_credit_card( height: nil, quality: nil ) - api_path = '/avatars/credit-cards/{code}' - .gsub('{code}', code) - if code.nil? raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/avatars/credit-cards/{code}' + .gsub('{code}', code) + api_params = { width: width, height: height, @@ -114,12 +114,12 @@ def get_credit_card( def get_favicon( url: ) - api_path = '/avatars/favicon' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/avatars/favicon' + api_params = { url: url, } @@ -160,13 +160,13 @@ def get_flag( height: nil, quality: nil ) - api_path = '/avatars/flags/{code}' - .gsub('{code}', code) - if code.nil? raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/avatars/flags/{code}' + .gsub('{code}', code) + api_params = { width: width, height: height, @@ -208,12 +208,12 @@ def get_image( width: nil, height: nil ) - api_path = '/avatars/image' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/avatars/image' + api_params = { url: url, width: width, @@ -285,9 +285,9 @@ def get_initials( end # Returns the best available profile photo for a user. The endpoint tries - # each source in priority order and returns the first successful result: - # OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in - # static fallback. + # each source in priority order and returns the first successful result: a + # custom uploaded photo (see avatars.updatePhoto), OAuth2 identity photo, + # Gravatar, Libravatar, Appwrite Initials, built-in static fallback. # # Passing `userId` — `current()` for the authenticated user — resolves # the photo from everything known about that user: identity photos, email, @@ -433,12 +433,12 @@ def get_qr( margin: nil, download: nil ) - api_path = '/avatars/qr' - if text.nil? raise Appwrite::Exception.new('Missing required parameter: "text"') end + api_path = '/avatars/qr' + api_params = { text: text, size: size, @@ -471,7 +471,7 @@ def get_qr( # dimensions are not specified, the default viewport size is 1280x720px. # # @param [String] url Website URL which you want to capture. - # @param [Hash] headers HTTP headers to send with the browser request. Defaults to empty. + # @param [Hash] headers HTTP headers to send with the browser request. Only Accept and Accept-Language are allowed. Defaults to empty. # @param [Integer] viewport_width Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. # @param [Integer] viewport_height Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720. # @param [Float] scale Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1. @@ -514,12 +514,12 @@ def get_screenshot( quality: nil, output: nil ) - api_path = '/avatars/screenshots' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/avatars/screenshots' + api_params = { url: url, headers: headers, diff --git a/lib/appwrite/services/backups.rb b/lib/appwrite/services/backups.rb index f74a5917..9d58c7bf 100644 --- a/lib/appwrite/services/backups.rb +++ b/lib/appwrite/services/backups.rb @@ -44,12 +44,12 @@ def create_archive( services:, resource_id: nil ) - api_path = '/backups/archives' - if services.nil? raise Appwrite::Exception.new('Missing required parameter: "services"') end + api_path = '/backups/archives' + api_params = { services: services, resourceId: resource_id, @@ -78,13 +78,13 @@ def create_archive( def get_archive( archive_id: ) - api_path = '/backups/archives/{archiveId}' - .gsub('{archiveId}', archive_id) - - if archive_id.nil? + if archive_id.nil? || archive_id == '' raise Appwrite::Exception.new('Missing required parameter: "archiveId"') end + api_path = '/backups/archives/{archiveId}' + .gsub('{archiveId}', archive_id) + api_params = {} api_headers = { @@ -109,13 +109,13 @@ def get_archive( def delete_archive( archive_id: ) - api_path = '/backups/archives/{archiveId}' - .gsub('{archiveId}', archive_id) - - if archive_id.nil? + if archive_id.nil? || archive_id == '' raise Appwrite::Exception.new('Missing required parameter: "archiveId"') end + api_path = '/backups/archives/{archiveId}' + .gsub('{archiveId}', archive_id) + api_params = {} api_headers = { @@ -180,8 +180,6 @@ def create_policy( resource_id: nil, enabled: nil ) - api_path = '/backups/policies' - if policy_id.nil? raise Appwrite::Exception.new('Missing required parameter: "policyId"') end @@ -198,6 +196,8 @@ def create_policy( raise Appwrite::Exception.new('Missing required parameter: "schedule"') end + api_path = '/backups/policies' + api_params = { policyId: policy_id, name: name, @@ -231,13 +231,13 @@ def create_policy( def get_policy( policy_id: ) - api_path = '/backups/policies/{policyId}' - .gsub('{policyId}', policy_id) - - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/backups/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -270,13 +270,13 @@ def update_policy( schedule: nil, enabled: nil ) - api_path = '/backups/policies/{policyId}' - .gsub('{policyId}', policy_id) - - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/backups/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = { name: name, retention: retention, @@ -307,13 +307,13 @@ def update_policy( def delete_policy( policy_id: ) - api_path = '/backups/policies/{policyId}' - .gsub('{policyId}', policy_id) - - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/backups/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -375,8 +375,6 @@ def create_restoration( new_resource_id: nil, new_resource_name: nil ) - api_path = '/backups/restoration' - if archive_id.nil? raise Appwrite::Exception.new('Missing required parameter: "archiveId"') end @@ -385,6 +383,8 @@ def create_restoration( raise Appwrite::Exception.new('Missing required parameter: "services"') end + api_path = '/backups/restoration' + api_params = { archiveId: archive_id, services: services, @@ -443,13 +443,13 @@ def list_restorations( def get_restoration( restoration_id: ) - api_path = '/backups/restorations/{restorationId}' - .gsub('{restorationId}', restoration_id) - - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/backups/restorations/{restorationId}' + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/databases.rb b/lib/appwrite/services/databases.rb index c8783184..46bb76c1 100644 --- a/lib/appwrite/services/databases.rb +++ b/lib/appwrite/services/databases.rb @@ -60,8 +60,6 @@ def create( name:, enabled: nil ) - api_path = '/databases' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -70,6 +68,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/databases' + api_params = { databaseId: database_id, name: name, @@ -168,13 +168,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/databases/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -206,13 +206,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/databases/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -244,18 +244,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/databases/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -279,13 +280,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/databases/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -317,13 +318,13 @@ def create_operations( def get( database_id: ) - api_path = '/databases/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -355,13 +356,13 @@ def update( name: nil, enabled: nil ) - api_path = '/databases/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -394,18 +395,19 @@ def update( def delete( database_id: ) - api_path = '/databases/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -434,13 +436,13 @@ def list_collections( search: nil, total: nil ) - api_path = '/databases/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -476,7 +478,7 @@ def list_collections( # @param [] document_security Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] enabled Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. # @param [Array] attributes Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. - # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). # # @return [Collection] def create_collection( @@ -489,10 +491,7 @@ def create_collection( attributes: nil, indexes: nil ) - api_path = '/databases/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -504,6 +503,9 @@ def create_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/databases/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { collectionId: collection_id, name: name, @@ -543,18 +545,18 @@ def get_collection( database_id:, collection_id: ) - api_path = '/databases/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { @@ -594,18 +596,18 @@ def update_collection( enabled: nil, purge: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { name: name, permissions: permissions, @@ -643,23 +645,24 @@ def delete_collection( database_id:, collection_id: ) - api_path = '/databases/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -687,18 +690,18 @@ def list_attributes( queries: nil, total: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -745,15 +748,11 @@ def create_big_int_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -765,6 +764,10 @@ def create_big_int_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -816,20 +819,15 @@ def update_big_int_attribute( max: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -841,6 +839,11 @@ def update_big_int_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -886,15 +889,11 @@ def create_boolean_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -906,6 +905,10 @@ def create_boolean_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -950,20 +953,15 @@ def update_boolean_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -975,6 +973,11 @@ def update_boolean_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1017,15 +1020,11 @@ def create_datetime_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1037,6 +1036,10 @@ def create_datetime_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1081,20 +1084,15 @@ def update_datetime_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1106,6 +1104,11 @@ def update_datetime_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1149,15 +1152,11 @@ def create_email_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1169,6 +1168,10 @@ def create_email_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1214,20 +1217,15 @@ def update_email_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1239,6 +1237,11 @@ def update_email_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1285,15 +1288,11 @@ def create_enum_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1309,6 +1308,10 @@ def create_enum_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, elements: elements, @@ -1357,20 +1360,15 @@ def update_enum_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1386,6 +1384,11 @@ def update_enum_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { elements: elements, required: required, @@ -1435,15 +1438,11 @@ def create_float_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1455,6 +1454,10 @@ def create_float_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1506,20 +1509,15 @@ def update_float_attribute( max: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1531,6 +1529,11 @@ def update_float_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1581,15 +1584,11 @@ def create_integer_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1601,6 +1600,10 @@ def create_integer_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1652,20 +1655,15 @@ def update_integer_attribute( max: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1677,6 +1675,11 @@ def update_integer_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1722,15 +1725,11 @@ def create_ip_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1742,6 +1741,10 @@ def create_ip_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1787,20 +1790,15 @@ def update_ip_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1812,6 +1810,11 @@ def update_ip_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1852,15 +1855,11 @@ def create_line_attribute( required:, default: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1872,6 +1871,10 @@ def create_line_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1915,20 +1918,15 @@ def update_line_attribute( default: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1936,6 +1934,11 @@ def update_line_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1981,15 +1984,11 @@ def create_longtext_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2001,6 +2000,10 @@ def create_longtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2047,20 +2050,15 @@ def update_longtext_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2072,6 +2070,11 @@ def update_longtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2117,15 +2120,11 @@ def create_mediumtext_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2137,6 +2136,10 @@ def create_mediumtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2183,20 +2186,15 @@ def update_mediumtext_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2208,6 +2206,11 @@ def update_mediumtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2248,15 +2251,11 @@ def create_point_attribute( required:, default: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2268,6 +2267,10 @@ def create_point_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2311,20 +2314,15 @@ def update_point_attribute( default: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2332,6 +2330,11 @@ def update_point_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2372,15 +2375,11 @@ def create_polygon_attribute( required:, default: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2392,6 +2391,10 @@ def create_polygon_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2435,20 +2438,15 @@ def update_polygon_attribute( default: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2456,6 +2454,11 @@ def update_polygon_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2504,15 +2507,11 @@ def create_relationship_attribute( two_way_key: nil, on_delete: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2524,6 +2523,10 @@ def create_relationship_attribute( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { relatedCollectionId: related_collection_id, type: type, @@ -2569,23 +2572,23 @@ def update_relationship_attribute( on_delete: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { onDelete: on_delete, newKey: new_key, @@ -2632,15 +2635,11 @@ def create_string_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2656,6 +2655,10 @@ def create_string_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, size: size, @@ -2705,20 +2708,15 @@ def update_string_attribute( size: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2730,6 +2728,11 @@ def update_string_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2776,15 +2779,11 @@ def create_text_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2796,6 +2795,10 @@ def create_text_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2842,20 +2845,15 @@ def update_text_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2867,6 +2865,11 @@ def update_text_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2910,15 +2913,11 @@ def create_url_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2930,6 +2929,10 @@ def create_url_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2975,20 +2978,15 @@ def update_url_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3000,6 +2998,11 @@ def update_url_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3047,15 +3050,11 @@ def create_varchar_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3071,6 +3070,10 @@ def create_varchar_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, size: size, @@ -3120,20 +3123,15 @@ def update_varchar_attribute( size: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3145,6 +3143,11 @@ def update_varchar_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3176,29 +3179,29 @@ def update_varchar_attribute( # @param [String] collection_id Collection ID. # @param [String] key Attribute Key. # - # @return [AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributeString] + # @return [AttributeBoolean, AttributeBigint, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributePoint, AttributeLine, AttributePolygon, AttributeVarchar, AttributeText, AttributeMediumtext, AttributeLongtext, AttributeString] def get_attribute( database_id:, collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -3242,6 +3245,11 @@ def get_attribute( return Models::AttributeBoolean.from(map: response) end + if response['type'] == 'bigint' + + return Models::AttributeBigint.from(map: response) + end + if response['type'] == 'integer' return Models::AttributeInteger.from(map: response) @@ -3262,6 +3270,41 @@ def get_attribute( return Models::AttributeRelationship.from(map: response) end + if response['type'] == 'point' + + return Models::AttributePoint.from(map: response) + end + + if response['type'] == 'linestring' + + return Models::AttributeLine.from(map: response) + end + + if response['type'] == 'polygon' + + return Models::AttributePolygon.from(map: response) + end + + if response['type'] == 'varchar' + + return Models::AttributeVarchar.from(map: response) + end + + if response['type'] == 'text' + + return Models::AttributeText.from(map: response) + end + + if response['type'] == 'mediumtext' + + return Models::AttributeMediumtext.from(map: response) + end + + if response['type'] == 'longtext' + + return Models::AttributeLongtext.from(map: response) + end + if response['type'] == 'string' return Models::AttributeString.from(map: response) @@ -3285,28 +3328,29 @@ def delete_attribute( collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3339,18 +3383,18 @@ def list_documents( total: nil, ttl: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3396,15 +3440,11 @@ def create_document( permissions: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3416,6 +3456,10 @@ def create_document( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documentId: document_id, data: data, @@ -3458,15 +3502,11 @@ def create_documents( documents:, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3474,6 +3514,10 @@ def create_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -3515,15 +3559,11 @@ def upsert_documents( documents:, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3531,6 +3571,10 @@ def upsert_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -3572,18 +3616,18 @@ def update_documents( queries: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { data: data, queries: queries, @@ -3623,18 +3667,18 @@ def delete_documents( queries: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3675,23 +3719,23 @@ def get_document( queries: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3735,23 +3779,23 @@ def upsert_document( permissions: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -3795,23 +3839,23 @@ def update_document( permissions: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -3850,23 +3894,23 @@ def delete_document( document_id:, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { transactionId: transaction_id, } @@ -3874,6 +3918,7 @@ def delete_document( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3907,28 +3952,28 @@ def decrement_document_attribute( min: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, min: min, @@ -3973,28 +4018,28 @@ def increment_document_attribute( max: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, max: max, @@ -4033,18 +4078,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -4069,7 +4114,9 @@ def list_indexes( # # Creates an index on the attributes listed. Your index should include all # the attributes you will query in a single request. - # Attributes can be `key`, `fulltext`, and `unique`. + # Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. + # `trigram` is only available on PostgreSQL and lets `contains`, + # `startsWith`, and `endsWith` queries on string attributes use an index. # # @param [String] database_id Database ID. # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4089,15 +4136,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -4113,6 +4156,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "attributes"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, type: type, @@ -4151,23 +4198,23 @@ def get_index( collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -4199,28 +4246,29 @@ def delete_index( collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/documents_db.rb b/lib/appwrite/services/documents_db.rb index f97888a7..efa8021e 100644 --- a/lib/appwrite/services/documents_db.rb +++ b/lib/appwrite/services/documents_db.rb @@ -57,8 +57,6 @@ def create( replicas: nil, sync_mode: nil ) - api_path = '/documentsdb' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -67,6 +65,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb' + api_params = { databaseId: database_id, name: name, @@ -92,8 +92,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -184,13 +184,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/documentsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/documentsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -254,18 +254,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/documentsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -286,13 +287,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/documentsdb/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -321,13 +322,13 @@ def create_operations( def get( database_id: ) - api_path = '/documentsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -362,10 +363,7 @@ def update( replicas: nil, sync_mode: nil ) - api_path = '/documentsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -373,6 +371,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -405,18 +406,19 @@ def update( def delete( database_id: ) - api_path = '/documentsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -442,13 +444,13 @@ def list_collections( search: nil, total: nil ) - api_path = '/documentsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -494,10 +496,7 @@ def create_collection( attributes: nil, indexes: nil ) - api_path = '/documentsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -509,6 +508,9 @@ def create_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { collectionId: collection_id, name: name, @@ -545,18 +547,18 @@ def get_collection( database_id:, collection_id: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { @@ -593,15 +595,11 @@ def update_collection( enabled: nil, purge: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -609,6 +607,10 @@ def update_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { name: name, permissions: permissions, @@ -643,23 +645,24 @@ def delete_collection( database_id:, collection_id: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -689,18 +692,18 @@ def list_documents( total: nil, ttl: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -743,15 +746,11 @@ def create_document( permissions: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -763,6 +762,10 @@ def create_document( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documentId: document_id, data: data, @@ -802,15 +805,11 @@ def create_documents( documents:, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -818,6 +817,10 @@ def create_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -856,15 +859,11 @@ def upsert_documents( documents:, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -872,6 +871,10 @@ def upsert_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -910,18 +913,18 @@ def update_documents( queries: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { data: data, queries: queries, @@ -958,18 +961,18 @@ def delete_documents( queries: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1007,23 +1010,23 @@ def get_document( queries: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1064,23 +1067,23 @@ def upsert_document( permissions: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1121,23 +1124,23 @@ def update_document( permissions: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1173,23 +1176,23 @@ def delete_document( document_id:, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { transactionId: transaction_id, } @@ -1197,6 +1200,7 @@ def delete_document( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1227,28 +1231,28 @@ def decrement_document_attribute( min: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, min: min, @@ -1290,28 +1294,28 @@ def increment_document_attribute( max: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, max: max, @@ -1347,18 +1351,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -1400,15 +1404,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1424,6 +1424,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "attributes"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, type: type, @@ -1459,23 +1463,23 @@ def get_index( collection_id:, key: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -1504,28 +1508,29 @@ def delete_index( collection_id:, key: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1554,13 +1559,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/documentsdb/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1597,13 +1602,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/documentsdb/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1633,13 +1638,13 @@ def list_operations( def get_replicas( database_id: ) - api_path = '/documentsdb/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1666,13 +1671,13 @@ def get_replicas( def get_status( database_id: ) - api_path = '/documentsdb/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/domains.rb b/lib/appwrite/services/domains.rb index 3493e9e4..42937c7d 100644 --- a/lib/appwrite/services/domains.rb +++ b/lib/appwrite/services/domains.rb @@ -174,7 +174,7 @@ def list_prices( def get( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -208,7 +208,7 @@ def get( def delete( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -243,7 +243,7 @@ def update_nameservers( domain_id:, nameservers: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -281,7 +281,7 @@ def update_nameservers( def verify_nameservers( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -313,7 +313,7 @@ def verify_nameservers( def get_preset_google_workspace( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -346,7 +346,7 @@ def get_preset_google_workspace( def create_preset_google_workspace( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -378,7 +378,7 @@ def create_preset_google_workspace( def get_preset_i_cloud( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -411,7 +411,7 @@ def get_preset_i_cloud( def create_preset_i_cloud( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -443,7 +443,7 @@ def create_preset_i_cloud( def get_preset_mailgun( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -476,7 +476,7 @@ def get_preset_mailgun( def create_preset_mailgun( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -508,7 +508,7 @@ def create_preset_mailgun( def get_preset_outlook( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -541,7 +541,7 @@ def get_preset_outlook( def create_preset_outlook( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -573,7 +573,7 @@ def create_preset_outlook( def get_preset_proton_mail( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -606,7 +606,7 @@ def get_preset_proton_mail( def create_preset_proton_mail( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -638,7 +638,7 @@ def create_preset_proton_mail( def get_preset_zoho( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -671,7 +671,7 @@ def get_preset_zoho( def create_preset_zoho( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -707,7 +707,7 @@ def list_records( domain_id:, queries: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -750,7 +750,7 @@ def create_record_a( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -813,11 +813,11 @@ def update_record_a( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -878,7 +878,7 @@ def create_record_aaaa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -941,11 +941,11 @@ def update_record_aaaa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1007,7 +1007,7 @@ def create_record_alias( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1073,11 +1073,11 @@ def update_record_alias( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1138,7 +1138,7 @@ def create_record_caa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1201,11 +1201,11 @@ def update_record_caa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1269,7 +1269,7 @@ def create_record_cname( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1328,11 +1328,11 @@ def update_record_cname( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1392,7 +1392,7 @@ def create_record_https( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1455,11 +1455,11 @@ def update_record_https( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1525,7 +1525,7 @@ def create_record_mx( priority:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1591,11 +1591,11 @@ def update_record_mx( priority:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1661,7 +1661,7 @@ def create_record_ns( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1726,11 +1726,11 @@ def update_record_ns( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1798,7 +1798,7 @@ def create_record_srv( port:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1891,11 +1891,11 @@ def update_record_srv( port:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1970,7 +1970,7 @@ def create_record_txt( value: nil, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2030,11 +2030,11 @@ def update_record_txt( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -2092,11 +2092,11 @@ def get_record( domain_id:, record_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -2132,11 +2132,11 @@ def delete_record( domain_id:, record_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -2176,7 +2176,7 @@ def update_team( domain_id:, team_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2215,7 +2215,7 @@ def update_team( def get_transfer_status( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2249,7 +2249,7 @@ def get_transfer_status( def get_zone( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2285,7 +2285,7 @@ def update_zone( domain_id:, content: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end diff --git a/lib/appwrite/services/embeddings.rb b/lib/appwrite/services/embeddings.rb index 3b7003db..e4fb2813 100644 --- a/lib/appwrite/services/embeddings.rb +++ b/lib/appwrite/services/embeddings.rb @@ -19,12 +19,12 @@ def create_text_embeddings( texts:, model: nil ) - api_path = '/embeddings/text' - if texts.nil? raise Appwrite::Exception.new('Missing required parameter: "texts"') end + api_path = '/embeddings/text' + api_params = { texts: texts, model: model, diff --git a/lib/appwrite/services/functions.rb b/lib/appwrite/services/functions.rb index dcf47e0c..d8dff4c0 100644 --- a/lib/appwrite/services/functions.rb +++ b/lib/appwrite/services/functions.rb @@ -96,8 +96,6 @@ def create( deployment_retention: nil, interval: nil ) - api_path = '/functions' - if function_id.nil? raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -110,6 +108,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "runtime"') end + api_path = '/functions' + api_params = { functionId: function_id, name: name, @@ -218,13 +218,13 @@ def list_specifications( def get( function_id: ) - api_path = '/functions/{functionId}' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}' + .gsub('{functionId}', function_id) + api_params = {} api_headers = { @@ -293,10 +293,7 @@ def update( deployment_retention: nil, interval: nil ) - api_path = '/functions/{functionId}' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -304,6 +301,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/functions/{functionId}' + .gsub('{functionId}', function_id) + api_params = { name: name, runtime: runtime, @@ -352,18 +352,19 @@ def update( def delete( function_id: ) - api_path = '/functions/{functionId}' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}' + .gsub('{functionId}', function_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -385,10 +386,7 @@ def update_function_deployment( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployment' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -396,6 +394,9 @@ def update_function_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployment' + .gsub('{functionId}', function_id) + api_params = { deploymentId: deployment_id, } @@ -430,13 +431,13 @@ def list_deployments( search: nil, total: nil ) - api_path = '/functions/{functionId}/deployments' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/deployments' + .gsub('{functionId}', function_id) + api_params = { queries: queries, search: search, @@ -483,10 +484,7 @@ def create_deployment( commands: nil, on_progress: nil ) - api_path = '/functions/{functionId}/deployments' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -498,6 +496,9 @@ def create_deployment( raise Appwrite::Exception.new('Missing required parameter: "activate"') end + api_path = '/functions/{functionId}/deployments' + .gsub('{functionId}', function_id) + api_params = { entrypoint: entrypoint, commands: commands, @@ -521,6 +522,7 @@ def create_deployment( param_name: param_name, id_param_name: id_param_name, on_progress: on_progress, + method: 'POST', response_type: Models::Deployment ) end @@ -541,10 +543,7 @@ def create_duplicate_deployment( deployment_id:, build_id: nil ) - api_path = '/functions/{functionId}/deployments/duplicate' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -552,6 +551,9 @@ def create_duplicate_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/duplicate' + .gsub('{functionId}', function_id) + api_params = { deploymentId: deployment_id, buildId: build_id, @@ -596,10 +598,7 @@ def create_template_deployment( reference:, activate: nil ) - api_path = '/functions/{functionId}/deployments/template' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -623,6 +622,9 @@ def create_template_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/functions/{functionId}/deployments/template' + .gsub('{functionId}', function_id) + api_params = { repository: repository, owner: owner, @@ -663,10 +665,7 @@ def create_vcs_deployment( reference:, activate: nil ) - api_path = '/functions/{functionId}/deployments/vcs' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -678,6 +677,9 @@ def create_vcs_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/functions/{functionId}/deployments/vcs' + .gsub('{functionId}', function_id) + api_params = { type: type, reference: reference, @@ -709,18 +711,18 @@ def get_deployment( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployments/{deploymentId}' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -747,23 +749,24 @@ def delete_deployment( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployments/{deploymentId}' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -790,18 +793,18 @@ def get_deployment_download( type: nil, token: nil ) - api_path = '/functions/{functionId}/deployments/{deploymentId}/download' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}/download' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = { type: type, token: token, @@ -834,18 +837,18 @@ def update_deployment_status( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployments/{deploymentId}/status' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}/status' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -876,13 +879,13 @@ def list_executions( queries: nil, total: nil ) - api_path = '/functions/{functionId}/executions' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/executions' + .gsub('{functionId}', function_id) + api_params = { queries: queries, total: total, @@ -925,13 +928,13 @@ def create_execution( headers: nil, scheduled_at: nil ) - api_path = '/functions/{functionId}/executions' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/executions' + .gsub('{functionId}', function_id) + api_params = { body: body, async: async, @@ -966,18 +969,18 @@ def get_execution( function_id:, execution_id: ) - api_path = '/functions/{functionId}/executions/{executionId}' - .gsub('{functionId}', function_id) - .gsub('{executionId}', execution_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if execution_id.nil? + if execution_id.nil? || execution_id == '' raise Appwrite::Exception.new('Missing required parameter: "executionId"') end + api_path = '/functions/{functionId}/executions/{executionId}' + .gsub('{functionId}', function_id) + .gsub('{executionId}', execution_id) + api_params = {} api_headers = { @@ -1004,23 +1007,24 @@ def delete_execution( function_id:, execution_id: ) - api_path = '/functions/{functionId}/executions/{executionId}' - .gsub('{functionId}', function_id) - .gsub('{executionId}', execution_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if execution_id.nil? + if execution_id.nil? || execution_id == '' raise Appwrite::Exception.new('Missing required parameter: "executionId"') end + api_path = '/functions/{functionId}/executions/{executionId}' + .gsub('{functionId}', function_id) + .gsub('{executionId}', execution_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1043,13 +1047,13 @@ def list_variables( queries: nil, total: nil ) - api_path = '/functions/{functionId}/variables' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/variables' + .gsub('{functionId}', function_id) + api_params = { queries: queries, total: total, @@ -1086,10 +1090,7 @@ def create_variable( value:, secret: nil ) - api_path = '/functions/{functionId}/variables' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -1105,6 +1106,9 @@ def create_variable( raise Appwrite::Exception.new('Missing required parameter: "value"') end + api_path = '/functions/{functionId}/variables' + .gsub('{functionId}', function_id) + api_params = { variableId: variable_id, key: key, @@ -1137,18 +1141,18 @@ def get_variable( function_id:, variable_id: ) - api_path = '/functions/{functionId}/variables/{variableId}' - .gsub('{functionId}', function_id) - .gsub('{variableId}', variable_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/functions/{functionId}/variables/{variableId}' + .gsub('{functionId}', function_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { @@ -1181,18 +1185,18 @@ def update_variable( value: nil, secret: nil ) - api_path = '/functions/{functionId}/variables/{variableId}' - .gsub('{functionId}', function_id) - .gsub('{variableId}', variable_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/functions/{functionId}/variables/{variableId}' + .gsub('{functionId}', function_id) + .gsub('{variableId}', variable_id) + api_params = { key: key, value: value, @@ -1224,23 +1228,24 @@ def delete_variable( function_id:, variable_id: ) - api_path = '/functions/{functionId}/variables/{variableId}' - .gsub('{functionId}', function_id) - .gsub('{variableId}', variable_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/functions/{functionId}/variables/{variableId}' + .gsub('{functionId}', function_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/graphql.rb b/lib/appwrite/services/graphql.rb index 210f528a..7a13b000 100644 --- a/lib/appwrite/services/graphql.rb +++ b/lib/appwrite/services/graphql.rb @@ -14,12 +14,12 @@ def initialize(client) def query( query: ) - api_path = '/graphql' - if query.nil? raise Appwrite::Exception.new('Missing required parameter: "query"') end + api_path = '/graphql' + api_params = { query: query, } @@ -47,12 +47,12 @@ def query( def mutation( query: ) - api_path = '/graphql/mutation' - if query.nil? raise Appwrite::Exception.new('Missing required parameter: "query"') end + api_path = '/graphql/mutation' + api_params = { query: query, } diff --git a/lib/appwrite/services/messaging.rb b/lib/appwrite/services/messaging.rb index ab97d81c..e37e067d 100644 --- a/lib/appwrite/services/messaging.rb +++ b/lib/appwrite/services/messaging.rb @@ -8,7 +8,7 @@ def initialize(client) # Get a list of all messages from the current Appwrite project. # - # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType + # @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: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType, users, targets # @param [String] search Search term to filter your list results. Max length: 256 chars. # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # @@ -74,8 +74,6 @@ def create_email( reply_to_email: nil, reply_to_name: nil ) - api_path = '/messaging/messages/email' - if message_id.nil? raise Appwrite::Exception.new('Missing required parameter: "messageId"') end @@ -88,6 +86,8 @@ def create_email( raise Appwrite::Exception.new('Missing required parameter: "content"') end + api_path = '/messaging/messages/email' + api_params = { messageId: message_id, subject: subject, @@ -157,13 +157,13 @@ def update_email( reply_to_email: nil, reply_to_name: nil ) - api_path = '/messaging/messages/email/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/email/{messageId}' + .gsub('{messageId}', message_id) + api_params = { topics: topics, users: users, @@ -241,12 +241,12 @@ def create_push( priority: nil, channel_id: nil ) - api_path = '/messaging/messages/push' - if message_id.nil? raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/push' + api_params = { messageId: message_id, title: title, @@ -334,13 +334,13 @@ def update_push( priority: nil, channel_id: nil ) - api_path = '/messaging/messages/push/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/push/{messageId}' + .gsub('{messageId}', message_id) + api_params = { topics: topics, users: users, @@ -398,8 +398,6 @@ def create_sms( draft: nil, scheduled_at: nil ) - api_path = '/messaging/messages/sms' - if message_id.nil? raise Appwrite::Exception.new('Missing required parameter: "messageId"') end @@ -408,6 +406,8 @@ def create_sms( raise Appwrite::Exception.new('Missing required parameter: "content"') end + api_path = '/messaging/messages/sms' + api_params = { messageId: message_id, content: content, @@ -456,13 +456,13 @@ def update_sms( draft: nil, scheduled_at: nil ) - api_path = '/messaging/messages/sms/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/sms/{messageId}' + .gsub('{messageId}', message_id) + api_params = { topics: topics, users: users, @@ -496,13 +496,13 @@ def update_sms( def get_message( message_id: ) - api_path = '/messaging/messages/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/{messageId}' + .gsub('{messageId}', message_id) + api_params = {} api_headers = { @@ -528,18 +528,19 @@ def get_message( def delete( message_id: ) - api_path = '/messaging/messages/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/{messageId}' + .gsub('{messageId}', message_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -562,13 +563,13 @@ def list_targets( queries: nil, total: nil ) - api_path = '/messaging/messages/{messageId}/targets' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/{messageId}/targets' + .gsub('{messageId}', message_id) + api_params = { queries: queries, total: total, @@ -644,8 +645,6 @@ def create_apns_provider( sandbox: nil, enabled: nil ) - api_path = '/messaging/providers/apns' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -654,6 +653,8 @@ def create_apns_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/apns' + api_params = { providerId: provider_id, name: name, @@ -702,13 +703,13 @@ def update_apns_provider( bundle_id: nil, sandbox: nil ) - api_path = '/messaging/providers/apns/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/apns/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -740,7 +741,7 @@ def update_apns_provider( # @param [String] name Provider name. # @param [] enabled Set as enabled. # @param [Integer] qos Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. # # @return [Provider] def create_appwrite_provider( @@ -789,7 +790,7 @@ def create_appwrite_provider( # @param [String] name Provider name. # @param [] enabled Set as enabled. # @param [Integer] qos Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. # # @return [Provider] def update_appwrite_provider( @@ -799,7 +800,7 @@ def update_appwrite_provider( qos: nil, expiry: nil ) - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -842,8 +843,6 @@ def create_fcm_provider( service_account_json: nil, enabled: nil ) - api_path = '/messaging/providers/fcm' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -852,6 +851,8 @@ def create_fcm_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/fcm' + api_params = { providerId: provider_id, name: name, @@ -888,13 +889,13 @@ def update_fcm_provider( enabled: nil, service_account_json: nil ) - api_path = '/messaging/providers/fcm/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/fcm/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -942,8 +943,6 @@ def create_mailgun_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/mailgun' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -952,6 +951,8 @@ def create_mailgun_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/mailgun' + api_params = { providerId: provider_id, name: name, @@ -1006,13 +1007,13 @@ def update_mailgun_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/mailgun/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/mailgun/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, apiKey: api_key, @@ -1058,8 +1059,6 @@ def create_msg91_provider( auth_key: nil, enabled: nil ) - api_path = '/messaging/providers/msg91' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1068,6 +1067,8 @@ def create_msg91_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/msg91' + api_params = { providerId: provider_id, name: name, @@ -1110,13 +1111,13 @@ def update_msg91_provider( sender_id: nil, auth_key: nil ) - api_path = '/messaging/providers/msg91/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/msg91/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1162,8 +1163,6 @@ def create_resend_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/resend' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1172,6 +1171,8 @@ def create_resend_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/resend' + api_params = { providerId: provider_id, name: name, @@ -1220,13 +1221,13 @@ def update_resend_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/resend/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/resend/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1274,8 +1275,6 @@ def create_sendgrid_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/sendgrid' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1284,6 +1283,8 @@ def create_sendgrid_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/sendgrid' + api_params = { providerId: provider_id, name: name, @@ -1332,13 +1333,13 @@ def update_sendgrid_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/sendgrid/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/sendgrid/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1390,8 +1391,6 @@ def create_ses_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/ses' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1400,6 +1399,8 @@ def create_ses_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/ses' + api_params = { providerId: provider_id, name: name, @@ -1454,13 +1455,13 @@ def update_ses_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/ses/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/ses/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1522,8 +1523,6 @@ def create_smtp_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/smtp' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1536,6 +1535,8 @@ def create_smtp_provider( raise Appwrite::Exception.new('Missing required parameter: "host"') end + api_path = '/messaging/providers/smtp' + api_params = { providerId: provider_id, name: name, @@ -1602,13 +1603,13 @@ def update_smtp_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/smtp/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/smtp/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, host: host, @@ -1658,8 +1659,6 @@ def create_telesign_provider( api_key: nil, enabled: nil ) - api_path = '/messaging/providers/telesign' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1668,6 +1667,8 @@ def create_telesign_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/telesign' + api_params = { providerId: provider_id, name: name, @@ -1710,13 +1711,13 @@ def update_telesign_provider( api_key: nil, from: nil ) - api_path = '/messaging/providers/telesign/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/telesign/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1758,8 +1759,6 @@ def create_textmagic_provider( api_key: nil, enabled: nil ) - api_path = '/messaging/providers/textmagic' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1768,6 +1767,8 @@ def create_textmagic_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/textmagic' + api_params = { providerId: provider_id, name: name, @@ -1810,13 +1811,13 @@ def update_textmagic_provider( api_key: nil, from: nil ) - api_path = '/messaging/providers/textmagic/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/textmagic/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1844,7 +1845,7 @@ def update_textmagic_provider( # # @param [String] provider_id Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. # @param [String] name Provider name. - # @param [String] from Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + # @param [String] from Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. # @param [String] account_sid Twilio account secret ID. # @param [String] auth_token Twilio authentication token. # @param [] enabled Set as enabled. @@ -1858,8 +1859,6 @@ def create_twilio_provider( auth_token: nil, enabled: nil ) - api_path = '/messaging/providers/twilio' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1868,6 +1867,8 @@ def create_twilio_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/twilio' + api_params = { providerId: provider_id, name: name, @@ -1899,7 +1900,7 @@ def create_twilio_provider( # @param [] enabled Set as enabled. # @param [String] account_sid Twilio account secret ID. # @param [String] auth_token Twilio authentication token. - # @param [String] from Sender number. + # @param [String] from Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. # # @return [Provider] def update_twilio_provider( @@ -1910,13 +1911,13 @@ def update_twilio_provider( auth_token: nil, from: nil ) - api_path = '/messaging/providers/twilio/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/twilio/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1958,8 +1959,6 @@ def create_vonage_provider( api_secret: nil, enabled: nil ) - api_path = '/messaging/providers/vonage' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1968,6 +1967,8 @@ def create_vonage_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/vonage' + api_params = { providerId: provider_id, name: name, @@ -2010,13 +2011,13 @@ def update_vonage_provider( api_secret: nil, from: nil ) - api_path = '/messaging/providers/vonage/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/vonage/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -2049,13 +2050,13 @@ def update_vonage_provider( def get_provider( provider_id: ) - api_path = '/messaging/providers/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/{providerId}' + .gsub('{providerId}', provider_id) + api_params = {} api_headers = { @@ -2080,18 +2081,19 @@ def get_provider( def delete_provider( provider_id: ) - api_path = '/messaging/providers/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/{providerId}' + .gsub('{providerId}', provider_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -2142,7 +2144,7 @@ def list_topics( # @param [String] name Topic Name. # @param [Array] subscribe An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. # @param [Integer] qos MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. # # @return [Topic] def create_topic( @@ -2152,8 +2154,6 @@ def create_topic( qos: nil, expiry: nil ) - api_path = '/messaging/topics' - if topic_id.nil? raise Appwrite::Exception.new('Missing required parameter: "topicId"') end @@ -2162,6 +2162,8 @@ def create_topic( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/topics' + api_params = { topicId: topic_id, name: name, @@ -2194,13 +2196,13 @@ def create_topic( def get_topic( topic_id: ) - api_path = '/messaging/topics/{topicId}' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}' + .gsub('{topicId}', topic_id) + api_params = {} api_headers = { @@ -2224,7 +2226,7 @@ def get_topic( # @param [String] name Topic Name. # @param [Array] subscribe An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. # @param [Integer] qos MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. # # @return [Topic] def update_topic( @@ -2234,13 +2236,13 @@ def update_topic( qos: nil, expiry: nil ) - api_path = '/messaging/topics/{topicId}' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}' + .gsub('{topicId}', topic_id) + api_params = { name: name, subscribe: subscribe, @@ -2271,18 +2273,19 @@ def update_topic( def delete_topic( topic_id: ) - api_path = '/messaging/topics/{topicId}' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}' + .gsub('{topicId}', topic_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -2307,13 +2310,13 @@ def list_subscribers( search: nil, total: nil ) - api_path = '/messaging/topics/{topicId}/subscribers' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}/subscribers' + .gsub('{topicId}', topic_id) + api_params = { queries: queries, search: search, @@ -2346,10 +2349,7 @@ def create_subscriber( subscriber_id:, target_id: ) - api_path = '/messaging/topics/{topicId}/subscribers' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end @@ -2361,6 +2361,9 @@ def create_subscriber( raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/messaging/topics/{topicId}/subscribers' + .gsub('{topicId}', topic_id) + api_params = { subscriberId: subscriber_id, targetId: target_id, @@ -2392,18 +2395,18 @@ def get_subscriber( topic_id:, subscriber_id: ) - api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' - .gsub('{topicId}', topic_id) - .gsub('{subscriberId}', subscriber_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end - if subscriber_id.nil? + if subscriber_id.nil? || subscriber_id == '' raise Appwrite::Exception.new('Missing required parameter: "subscriberId"') end + api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .gsub('{topicId}', topic_id) + .gsub('{subscriberId}', subscriber_id) + api_params = {} api_headers = { @@ -2430,23 +2433,24 @@ def delete_subscriber( topic_id:, subscriber_id: ) - api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' - .gsub('{topicId}', topic_id) - .gsub('{subscriberId}', subscriber_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end - if subscriber_id.nil? + if subscriber_id.nil? || subscriber_id == '' raise Appwrite::Exception.new('Missing required parameter: "subscriberId"') end + api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .gsub('{topicId}', topic_id) + .gsub('{subscriberId}', subscriber_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/mongo.rb b/lib/appwrite/services/mongo.rb index 0c95972a..89789257 100644 --- a/lib/appwrite/services/mongo.rb +++ b/lib/appwrite/services/mongo.rb @@ -50,7 +50,7 @@ def list( # @param [Integer] pitr_retention_days Number of days to retain PITR data. # @param [] storage_autoscaling Enable automatic storage expansion when usage exceeds threshold. # @param [Integer] storage_autoscaling_threshold_percent Storage usage percentage (50-95) that triggers automatic expansion. - # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. 0 means no limit. + # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. # # @return [DedicatedDatabase] def create( @@ -69,8 +69,6 @@ def create( storage_autoscaling_threshold_percent: nil, storage_autoscaling_max_gb: nil ) - api_path = '/mongo' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -79,6 +77,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/mongo' + api_params = { databaseId: database_id, name: name, @@ -112,8 +112,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -145,13 +145,13 @@ def list_specifications() def get( database_id: ) - api_path = '/mongo/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update( sql_api_max_bytes: nil, sql_api_timeout_seconds: nil ) - api_path = '/mongo/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, status: status, @@ -275,13 +275,13 @@ def update( def delete( database_id: ) - api_path = '/mongo/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -309,13 +309,13 @@ def list_backups( database_id:, queries: nil ) - api_path = '/mongo/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -345,13 +345,13 @@ def create_backup( database_id:, type: nil ) - api_path = '/mongo/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { type: type, } @@ -381,13 +381,13 @@ def list_backup_policies( database_id:, queries: nil ) - api_path = '/mongo/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -426,10 +426,7 @@ def create_backup_policy( type: nil, enabled: nil ) - api_path = '/mongo/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -449,6 +446,9 @@ def create_backup_policy( raise Appwrite::Exception.new('Missing required parameter: "retention"') end + api_path = '/mongo/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { policyId: policy_id, name: name, @@ -483,18 +483,18 @@ def get_backup_policy( database_id:, policy_id: ) - api_path = '/mongo/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mongo/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -529,18 +529,18 @@ def update_backup_policy( retention: nil, enabled: nil ) - api_path = '/mongo/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mongo/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = { name: name, schedule: schedule, @@ -574,18 +574,18 @@ def delete_backup_policy( database_id:, policy_id: ) - api_path = '/mongo/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mongo/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -626,10 +626,7 @@ def update_backup_storage( prefix: nil, endpoint: nil ) - api_path = '/mongo/{databaseId}/backups/storage' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -649,6 +646,9 @@ def update_backup_storage( raise Appwrite::Exception.new('Missing required parameter: "secretKey"') end + api_path = '/mongo/{databaseId}/backups/storage' + .gsub('{databaseId}', database_id) + api_params = { provider: provider, bucket: bucket, @@ -685,18 +685,18 @@ def get_backup( database_id:, backup_id: ) - api_path = '/mongo/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mongo/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -724,18 +724,18 @@ def delete_backup( database_id:, backup_id: ) - api_path = '/mongo/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mongo/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -761,13 +761,13 @@ def delete_backup( def list_branches( database_id: ) - api_path = '/mongo/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -800,13 +800,13 @@ def create_branch( branch_id: nil, ttl: nil ) - api_path = '/mongo/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = { branchId: branch_id, ttl: ttl, @@ -839,18 +839,18 @@ def delete_branch( database_id:, branch_id: ) - api_path = '/mongo/{databaseId}/branches/{branchId}' - .gsub('{databaseId}', database_id) - .gsub('{branchId}', branch_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if branch_id.nil? + if branch_id.nil? || branch_id == '' raise Appwrite::Exception.new('Missing required parameter: "branchId"') end + api_path = '/mongo/{databaseId}/branches/{branchId}' + .gsub('{databaseId}', database_id) + .gsub('{branchId}', branch_id) + api_params = {} api_headers = { @@ -879,13 +879,13 @@ def delete_branch( def update_credentials( database_id: ) - api_path = '/mongo/{databaseId}/credentials' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/credentials' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -921,13 +921,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/mongo/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -961,10 +961,7 @@ def update_maintenance( day:, hour_utc: ) - api_path = '/mongo/{databaseId}/maintenance' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -976,6 +973,9 @@ def update_maintenance( raise Appwrite::Exception.new('Missing required parameter: "hourUtc"') end + api_path = '/mongo/{databaseId}/maintenance' + .gsub('{databaseId}', database_id) + api_params = { day: day, hourUtc: hour_utc, @@ -1011,10 +1011,7 @@ def create_migration( target_type:, specification: nil ) - api_path = '/mongo/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1022,6 +1019,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "targetType"') end + api_path = '/mongo/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { targetType: target_type, specification: specification, @@ -1059,13 +1059,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/mongo/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1095,13 +1095,13 @@ def list_operations( def get_pitr( database_id: ) - api_path = '/mongo/{databaseId}/pitr' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/pitr' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1127,13 +1127,13 @@ def get_pitr( def get_replicas( database_id: ) - api_path = '/mongo/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1167,13 +1167,13 @@ def list_restorations( limit: nil, offset: nil ) - api_path = '/mongo/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { status: status, type: type, @@ -1214,13 +1214,13 @@ def create_restoration( target_database_id: nil, target_time: nil ) - api_path = '/mongo/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { type: type, backupId: backup_id, @@ -1254,18 +1254,18 @@ def get_restoration( database_id:, restoration_id: ) - api_path = '/mongo/{databaseId}/restorations/{restorationId}' - .gsub('{databaseId}', database_id) - .gsub('{restorationId}', restoration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/mongo/{databaseId}/restorations/{restorationId}' + .gsub('{databaseId}', database_id) + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { @@ -1292,13 +1292,13 @@ def get_restoration( def get_status( database_id: ) - api_path = '/mongo/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1326,10 +1326,7 @@ def create_upgrade( database_id:, target_version: ) - api_path = '/mongo/{databaseId}/upgrades' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1337,6 +1334,9 @@ def create_upgrade( raise Appwrite::Exception.new('Missing required parameter: "targetVersion"') end + api_path = '/mongo/{databaseId}/upgrades' + .gsub('{databaseId}', database_id) + api_params = { targetVersion: target_version, } diff --git a/lib/appwrite/services/mysql.rb b/lib/appwrite/services/mysql.rb index 2e21c83c..065dcbc6 100644 --- a/lib/appwrite/services/mysql.rb +++ b/lib/appwrite/services/mysql.rb @@ -50,7 +50,7 @@ def list( # @param [Integer] pitr_retention_days Number of days to retain PITR data. # @param [] storage_autoscaling Enable automatic storage expansion when usage exceeds threshold. # @param [Integer] storage_autoscaling_threshold_percent Storage usage percentage (50-95) that triggers automatic expansion. - # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. 0 means no limit. + # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. # # @return [DedicatedDatabase] def create( @@ -69,8 +69,6 @@ def create( storage_autoscaling_threshold_percent: nil, storage_autoscaling_max_gb: nil ) - api_path = '/mysql' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -79,6 +77,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/mysql' + api_params = { databaseId: database_id, name: name, @@ -112,8 +112,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -145,13 +145,13 @@ def list_specifications() def get( database_id: ) - api_path = '/mysql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update( sql_api_max_bytes: nil, sql_api_timeout_seconds: nil ) - api_path = '/mysql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, status: status, @@ -275,13 +275,13 @@ def update( def delete( database_id: ) - api_path = '/mysql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -309,13 +309,13 @@ def list_backups( database_id:, queries: nil ) - api_path = '/mysql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -345,13 +345,13 @@ def create_backup( database_id:, type: nil ) - api_path = '/mysql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { type: type, } @@ -381,13 +381,13 @@ def list_backup_policies( database_id:, queries: nil ) - api_path = '/mysql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -426,10 +426,7 @@ def create_backup_policy( type: nil, enabled: nil ) - api_path = '/mysql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -449,6 +446,9 @@ def create_backup_policy( raise Appwrite::Exception.new('Missing required parameter: "retention"') end + api_path = '/mysql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { policyId: policy_id, name: name, @@ -483,18 +483,18 @@ def get_backup_policy( database_id:, policy_id: ) - api_path = '/mysql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mysql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -529,18 +529,18 @@ def update_backup_policy( retention: nil, enabled: nil ) - api_path = '/mysql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mysql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = { name: name, schedule: schedule, @@ -574,18 +574,18 @@ def delete_backup_policy( database_id:, policy_id: ) - api_path = '/mysql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mysql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -626,10 +626,7 @@ def update_backup_storage( prefix: nil, endpoint: nil ) - api_path = '/mysql/{databaseId}/backups/storage' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -649,6 +646,9 @@ def update_backup_storage( raise Appwrite::Exception.new('Missing required parameter: "secretKey"') end + api_path = '/mysql/{databaseId}/backups/storage' + .gsub('{databaseId}', database_id) + api_params = { provider: provider, bucket: bucket, @@ -685,18 +685,18 @@ def get_backup( database_id:, backup_id: ) - api_path = '/mysql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mysql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -724,18 +724,18 @@ def delete_backup( database_id:, backup_id: ) - api_path = '/mysql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mysql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -761,13 +761,13 @@ def delete_backup( def list_branches( database_id: ) - api_path = '/mysql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -800,13 +800,13 @@ def create_branch( branch_id: nil, ttl: nil ) - api_path = '/mysql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = { branchId: branch_id, ttl: ttl, @@ -839,18 +839,18 @@ def delete_branch( database_id:, branch_id: ) - api_path = '/mysql/{databaseId}/branches/{branchId}' - .gsub('{databaseId}', database_id) - .gsub('{branchId}', branch_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if branch_id.nil? + if branch_id.nil? || branch_id == '' raise Appwrite::Exception.new('Missing required parameter: "branchId"') end + api_path = '/mysql/{databaseId}/branches/{branchId}' + .gsub('{databaseId}', database_id) + .gsub('{branchId}', branch_id) + api_params = {} api_headers = { @@ -879,13 +879,13 @@ def delete_branch( def update_credentials( database_id: ) - api_path = '/mysql/{databaseId}/credentials' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/credentials' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -925,10 +925,7 @@ def create_execution( bindings: nil, timeout_seconds: nil ) - api_path = '/mysql/{databaseId}/executions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -936,6 +933,9 @@ def create_execution( raise Appwrite::Exception.new('Missing required parameter: "sql"') end + api_path = '/mysql/{databaseId}/executions' + .gsub('{databaseId}', database_id) + api_params = { sql: sql, bindings: bindings, @@ -975,13 +975,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/mysql/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1015,10 +1015,7 @@ def update_maintenance( day:, hour_utc: ) - api_path = '/mysql/{databaseId}/maintenance' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1030,6 +1027,9 @@ def update_maintenance( raise Appwrite::Exception.new('Missing required parameter: "hourUtc"') end + api_path = '/mysql/{databaseId}/maintenance' + .gsub('{databaseId}', database_id) + api_params = { day: day, hourUtc: hour_utc, @@ -1065,10 +1065,7 @@ def create_migration( target_type:, specification: nil ) - api_path = '/mysql/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1076,6 +1073,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "targetType"') end + api_path = '/mysql/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { targetType: target_type, specification: specification, @@ -1113,13 +1113,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/mysql/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1149,13 +1149,13 @@ def list_operations( def get_pitr( database_id: ) - api_path = '/mysql/{databaseId}/pitr' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/pitr' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1181,13 +1181,13 @@ def get_pitr( def get_pooler( database_id: ) - api_path = '/mysql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1229,13 +1229,13 @@ def update_pooler( pooler_memory_request: nil, pooler_memory_limit: nil ) - api_path = '/mysql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = { mode: mode, maxConnections: max_connections, @@ -1271,13 +1271,13 @@ def update_pooler( def get_replicas( database_id: ) - api_path = '/mysql/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1311,13 +1311,13 @@ def list_restorations( limit: nil, offset: nil ) - api_path = '/mysql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { status: status, type: type, @@ -1358,13 +1358,13 @@ def create_restoration( target_database_id: nil, target_time: nil ) - api_path = '/mysql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { type: type, backupId: backup_id, @@ -1398,18 +1398,18 @@ def get_restoration( database_id:, restoration_id: ) - api_path = '/mysql/{databaseId}/restorations/{restorationId}' - .gsub('{databaseId}', database_id) - .gsub('{restorationId}', restoration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/mysql/{databaseId}/restorations/{restorationId}' + .gsub('{databaseId}', database_id) + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { @@ -1436,13 +1436,13 @@ def get_restoration( def get_status( database_id: ) - api_path = '/mysql/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1470,10 +1470,7 @@ def create_upgrade( database_id:, target_version: ) - api_path = '/mysql/{databaseId}/upgrades' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1481,6 +1478,9 @@ def create_upgrade( raise Appwrite::Exception.new('Missing required parameter: "targetVersion"') end + api_path = '/mysql/{databaseId}/upgrades' + .gsub('{databaseId}', database_id) + api_params = { targetVersion: target_version, } diff --git a/lib/appwrite/services/oauth2.rb b/lib/appwrite/services/oauth2.rb index 33402a28..0571d694 100644 --- a/lib/appwrite/services/oauth2.rb +++ b/lib/appwrite/services/oauth2.rb @@ -22,13 +22,13 @@ def approve( 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_path = '/oauth2/{project_id}/approve' + .gsub('{project_id}', @client.get_config('project')) + api_params = { grant_id: grant_id, authorization_details: authorization_details, @@ -66,7 +66,7 @@ def approve( # @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 [Array] 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. # @@ -137,7 +137,7 @@ def authorize( # @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 [Array] 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. # @@ -198,7 +198,7 @@ def authorize_post( # @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 [Array] 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] @@ -245,13 +245,13 @@ def create_device_authorization( 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_path = '/oauth2/{project_id}/grants' + .gsub('{project_id}', @client.get_config('project')) + api_params = { user_code: user_code, } @@ -280,14 +280,14 @@ def create_grant( def get_grant( grant_id: ) + if grant_id.nil? || grant_id == '' + raise Appwrite::Exception.new('Missing required parameter: "grantId"') + end + 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 = { @@ -398,7 +398,7 @@ def list_organizations( # @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 [Array] 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] @@ -417,9 +417,6 @@ def create_par( 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 @@ -432,6 +429,9 @@ def create_par( raise Appwrite::Exception.new('Missing required parameter: "responseType"') end + api_path = '/oauth2/{project_id}/par' + .gsub('{project_id}', @client.get_config('project')) + api_params = { client_id: client_id, redirect_uri: redirect_uri, @@ -509,13 +509,13 @@ def list_projects( 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_path = '/oauth2/{project_id}/reject' + .gsub('{project_id}', @client.get_config('project')) + api_params = { grant_id: grant_id, } @@ -548,13 +548,13 @@ def revoke( 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_path = '/oauth2/{project_id}/revoke' + .gsub('{project_id}', @client.get_config('project')) + api_params = { token: token, token_type_hint: token_type_hint, @@ -586,7 +586,7 @@ def revoke( # @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 [Array] 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] @@ -602,13 +602,13 @@ def create_token( 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_path = '/oauth2/{project_id}/token' + .gsub('{project_id}', @client.get_config('project')) + api_params = { grant_type: grant_type, code: code, diff --git a/lib/appwrite/services/organization.rb b/lib/appwrite/services/organization.rb index b43b8f29..e086c703 100644 --- a/lib/appwrite/services/organization.rb +++ b/lib/appwrite/services/organization.rb @@ -37,12 +37,12 @@ def get() def update( name: ) - api_path = '/organization' - if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/organization' + api_params = { name: name, } @@ -75,6 +75,7 @@ def delete() api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -129,12 +130,12 @@ 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_path = '/organization/installations' + api_params = { appId: app_id, authorizationDetails: authorization_details, @@ -164,13 +165,13 @@ def create_installation( def get_installation( installation_id: ) - api_path = '/organization/installations/{installationId}' - .gsub('{installationId}', installation_id) - - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -200,13 +201,13 @@ def update_installation( installation_id:, authorization_details: nil ) - api_path = '/organization/installations/{installationId}' - .gsub('{installationId}', installation_id) - - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) + api_params = { authorizationDetails: authorization_details, } @@ -236,216 +237,21 @@ def update_installation( def delete_installation( installation_id: ) - api_path = '/organization/installations/{installationId}' - .gsub('{installationId}', installation_id) - - if installation_id.nil? + if installation_id.nil? || installation_id == '' 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 - # @param [] total When set to false, the total count returned will be 0 and will not be calculated. - # - # @return [KeyList] - def list_keys( - queries: nil, - total: nil - ) - api_path = '/organization/keys' - - api_params = { - queries: queries, - total: total, - } - - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), - "accept": 'application/json', - } - - @client.call( - method: 'GET', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::KeyList - ) - end - - # Create a new organization API key. - # - # @param [String] key_id Key ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - # @param [String] name Key name. Max length: 128 chars. - # @param [Array] scopes Key scopes list. Maximum of 200 scopes are allowed. - # @param [String] expire Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - # - # @return [Key] - def create_key( - key_id:, - name:, - scopes:, - expire: nil - ) - api_path = '/organization/keys' - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') - end - - if name.nil? - raise Appwrite::Exception.new('Missing required parameter: "name"') - end - - if scopes.nil? - raise Appwrite::Exception.new('Missing required parameter: "scopes"') - end - - api_params = { - keyId: key_id, - name: name, - scopes: scopes, - expire: expire, - } - - api_headers = { - "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::Key - ) - end - - # Get a key by its unique ID. This endpoint returns details about a specific - # API key in your organization including its scopes. - # - # @param [String] key_id Key unique ID. - # - # @return [Key] - def get_key( - key_id: - ) - api_path = '/organization/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') - end + api_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) api_params = {} - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), - "accept": 'application/json', - } - - @client.call( - method: 'GET', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::Key - ) - end - - # Update a key by its unique ID. Use this endpoint to update the name, - # scopes, or expiration time of an API key. - # - # @param [String] key_id Key unique ID. - # @param [String] name Key name. Max length: 128 chars. - # @param [Array] scopes Key scopes list. Maximum of 200 scopes are allowed. - # @param [String] expire Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - # - # @return [Key] - def update_key( - key_id:, - name:, - scopes:, - expire: nil - ) - api_path = '/organization/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') - end - - if name.nil? - raise Appwrite::Exception.new('Missing required parameter: "name"') - end - - if scopes.nil? - raise Appwrite::Exception.new('Missing required parameter: "scopes"') - end - - api_params = { - name: name, - scopes: scopes, - expire: expire, - } - api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } - @client.call( - method: 'PUT', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::Key - ) - end - - # Delete a key by its unique ID. Once deleted, the key can no longer be used - # to authenticate API calls. - # - # @param [String] key_id Key unique ID. - # - # @return [] - def delete_key( - key_id: - ) - api_path = '/organization/keys/{keyId}' - .gsub('{keyId}', key_id) - - 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', - } - @client.call( method: 'DELETE', path: api_path, @@ -508,12 +314,12 @@ def create_membership( url: nil, name: nil ) - api_path = '/organization/memberships' - if roles.nil? raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/organization/memberships' + api_params = { email: email, userId: user_id, @@ -546,13 +352,13 @@ def create_membership( def get_membership( membership_id: ) - api_path = '/organization/memberships/{membershipId}' - .gsub('{membershipId}', membership_id) - - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/organization/memberships/{membershipId}' + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { @@ -579,10 +385,7 @@ def update_membership( membership_id:, roles: ) - api_path = '/organization/memberships/{membershipId}' - .gsub('{membershipId}', membership_id) - - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end @@ -590,6 +393,9 @@ def update_membership( raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/organization/memberships/{membershipId}' + .gsub('{membershipId}', membership_id) + api_params = { roles: roles, } @@ -619,18 +425,19 @@ def update_membership( def delete_membership( membership_id: ) - api_path = '/organization/memberships/{membershipId}' - .gsub('{membershipId}', membership_id) - - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/organization/memberships/{membershipId}' + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -688,8 +495,6 @@ def create_project( name:, region: nil ) - api_path = '/organization/projects' - if project_id.nil? raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -698,6 +503,8 @@ def create_project( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/organization/projects' + api_params = { projectId: project_id, name: name, @@ -727,17 +534,18 @@ def create_project( def get_project( project_id: ) - api_path = '/organization/projects/{projectId}' - .gsub('{projectId}', project_id) - - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end + api_path = '/organization/projects/{projectId}' + .gsub('{projectId}', project_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', } @client.call( @@ -759,10 +567,7 @@ def update_project( project_id:, name: ) - api_path = '/organization/projects/{projectId}' - .gsub('{projectId}', project_id) - - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -770,6 +575,9 @@ def update_project( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/organization/projects/{projectId}' + .gsub('{projectId}', project_id) + api_params = { name: name, } @@ -797,18 +605,19 @@ def update_project( def delete_project( project_id: ) - api_path = '/organization/projects/{projectId}' - .gsub('{projectId}', project_id) - - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end + api_path = '/organization/projects/{projectId}' + .gsub('{projectId}', project_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -831,7 +640,7 @@ def list_project_keys( queries: nil, total: nil ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -874,7 +683,7 @@ def create_ephemeral_project_key( scopes:, duration: ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -919,11 +728,11 @@ def get_project_key( project_id:, key_id: ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end @@ -964,11 +773,11 @@ def update_project_key( scopes:, expire: nil ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end @@ -1016,11 +825,11 @@ def delete_project_key( project_id:, key_id: ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end diff --git a/lib/appwrite/services/postgresql.rb b/lib/appwrite/services/postgresql.rb index cd67e74e..1b702cd3 100644 --- a/lib/appwrite/services/postgresql.rb +++ b/lib/appwrite/services/postgresql.rb @@ -50,7 +50,7 @@ def list( # @param [Integer] pitr_retention_days Number of days to retain PITR data. # @param [] storage_autoscaling Enable automatic storage expansion when usage exceeds threshold. # @param [Integer] storage_autoscaling_threshold_percent Storage usage percentage (50-95) that triggers automatic expansion. - # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. 0 means no limit. + # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. # # @return [DedicatedDatabase] def create( @@ -69,8 +69,6 @@ def create( storage_autoscaling_threshold_percent: nil, storage_autoscaling_max_gb: nil ) - api_path = '/postgresql' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -79,6 +77,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/postgresql' + api_params = { databaseId: database_id, name: name, @@ -112,8 +112,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -145,13 +145,13 @@ def list_specifications() def get( database_id: ) - api_path = '/postgresql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update( sql_api_max_bytes: nil, sql_api_timeout_seconds: nil ) - api_path = '/postgresql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, status: status, @@ -275,13 +275,13 @@ def update( def delete( database_id: ) - api_path = '/postgresql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -309,13 +309,13 @@ def list_backups( database_id:, queries: nil ) - api_path = '/postgresql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -345,13 +345,13 @@ def create_backup( database_id:, type: nil ) - api_path = '/postgresql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { type: type, } @@ -381,13 +381,13 @@ def list_backup_policies( database_id:, queries: nil ) - api_path = '/postgresql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -426,10 +426,7 @@ def create_backup_policy( type: nil, enabled: nil ) - api_path = '/postgresql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -449,6 +446,9 @@ def create_backup_policy( raise Appwrite::Exception.new('Missing required parameter: "retention"') end + api_path = '/postgresql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { policyId: policy_id, name: name, @@ -483,18 +483,18 @@ def get_backup_policy( database_id:, policy_id: ) - api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -529,18 +529,18 @@ def update_backup_policy( retention: nil, enabled: nil ) - api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = { name: name, schedule: schedule, @@ -574,18 +574,18 @@ def delete_backup_policy( database_id:, policy_id: ) - api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -626,10 +626,7 @@ def update_backup_storage( prefix: nil, endpoint: nil ) - api_path = '/postgresql/{databaseId}/backups/storage' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -649,6 +646,9 @@ def update_backup_storage( raise Appwrite::Exception.new('Missing required parameter: "secretKey"') end + api_path = '/postgresql/{databaseId}/backups/storage' + .gsub('{databaseId}', database_id) + api_params = { provider: provider, bucket: bucket, @@ -685,18 +685,18 @@ def get_backup( database_id:, backup_id: ) - api_path = '/postgresql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/postgresql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -724,18 +724,18 @@ def delete_backup( database_id:, backup_id: ) - api_path = '/postgresql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/postgresql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -761,13 +761,13 @@ def delete_backup( def list_branches( database_id: ) - api_path = '/postgresql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -800,13 +800,13 @@ def create_branch( branch_id: nil, ttl: nil ) - api_path = '/postgresql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = { branchId: branch_id, ttl: ttl, @@ -839,18 +839,18 @@ def delete_branch( database_id:, branch_id: ) - api_path = '/postgresql/{databaseId}/branches/{branchId}' - .gsub('{databaseId}', database_id) - .gsub('{branchId}', branch_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if branch_id.nil? + if branch_id.nil? || branch_id == '' raise Appwrite::Exception.new('Missing required parameter: "branchId"') end + api_path = '/postgresql/{databaseId}/branches/{branchId}' + .gsub('{databaseId}', database_id) + .gsub('{branchId}', branch_id) + api_params = {} api_headers = { @@ -879,13 +879,13 @@ def delete_branch( def update_credentials( database_id: ) - api_path = '/postgresql/{databaseId}/credentials' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/credentials' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -925,10 +925,7 @@ def create_execution( bindings: nil, timeout_seconds: nil ) - api_path = '/postgresql/{databaseId}/executions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -936,6 +933,9 @@ def create_execution( raise Appwrite::Exception.new('Missing required parameter: "sql"') end + api_path = '/postgresql/{databaseId}/executions' + .gsub('{databaseId}', database_id) + api_params = { sql: sql, bindings: bindings, @@ -965,13 +965,13 @@ def create_execution( def list_extensions( database_id: ) - api_path = '/postgresql/{databaseId}/extensions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/extensions' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -999,10 +999,7 @@ def create_extension( database_id:, name: ) - api_path = '/postgresql/{databaseId}/extensions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1010,6 +1007,9 @@ def create_extension( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/postgresql/{databaseId}/extensions' + .gsub('{databaseId}', database_id) + api_params = { name: name, } @@ -1040,18 +1040,18 @@ def delete_extension( database_id:, extension_name: ) - api_path = '/postgresql/{databaseId}/extensions/{extensionName}' - .gsub('{databaseId}', database_id) - .gsub('{extensionName}', extension_name) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if extension_name.nil? + if extension_name.nil? || extension_name == '' raise Appwrite::Exception.new('Missing required parameter: "extensionName"') end + api_path = '/postgresql/{databaseId}/extensions/{extensionName}' + .gsub('{databaseId}', database_id) + .gsub('{extensionName}', extension_name) + api_params = {} api_headers = { @@ -1087,13 +1087,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/postgresql/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1127,10 +1127,7 @@ def update_maintenance( day:, hour_utc: ) - api_path = '/postgresql/{databaseId}/maintenance' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1142,6 +1139,9 @@ def update_maintenance( raise Appwrite::Exception.new('Missing required parameter: "hourUtc"') end + api_path = '/postgresql/{databaseId}/maintenance' + .gsub('{databaseId}', database_id) + api_params = { day: day, hourUtc: hour_utc, @@ -1177,10 +1177,7 @@ def create_migration( target_type:, specification: nil ) - api_path = '/postgresql/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1188,6 +1185,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "targetType"') end + api_path = '/postgresql/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { targetType: target_type, specification: specification, @@ -1225,13 +1225,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/postgresql/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1261,13 +1261,13 @@ def list_operations( def get_pitr( database_id: ) - api_path = '/postgresql/{databaseId}/pitr' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/pitr' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1293,13 +1293,13 @@ def get_pitr( def get_pooler( database_id: ) - api_path = '/postgresql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1341,13 +1341,13 @@ def update_pooler( pooler_memory_request: nil, pooler_memory_limit: nil ) - api_path = '/postgresql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = { mode: mode, maxConnections: max_connections, @@ -1383,13 +1383,13 @@ def update_pooler( def get_replicas( database_id: ) - api_path = '/postgresql/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1423,13 +1423,13 @@ def list_restorations( limit: nil, offset: nil ) - api_path = '/postgresql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { status: status, type: type, @@ -1470,13 +1470,13 @@ def create_restoration( target_database_id: nil, target_time: nil ) - api_path = '/postgresql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { type: type, backupId: backup_id, @@ -1510,18 +1510,18 @@ def get_restoration( database_id:, restoration_id: ) - api_path = '/postgresql/{databaseId}/restorations/{restorationId}' - .gsub('{databaseId}', database_id) - .gsub('{restorationId}', restoration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/postgresql/{databaseId}/restorations/{restorationId}' + .gsub('{databaseId}', database_id) + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { @@ -1548,13 +1548,13 @@ def get_restoration( def get_status( database_id: ) - api_path = '/postgresql/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1582,10 +1582,7 @@ def create_upgrade( database_id:, target_version: ) - api_path = '/postgresql/{databaseId}/upgrades' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1593,6 +1590,9 @@ def create_upgrade( raise Appwrite::Exception.new('Missing required parameter: "targetVersion"') end + api_path = '/postgresql/{databaseId}/upgrades' + .gsub('{databaseId}', database_id) + api_params = { targetVersion: target_version, } diff --git a/lib/appwrite/services/presences.rb b/lib/appwrite/services/presences.rb index 01a022ed..a90a17d2 100644 --- a/lib/appwrite/services/presences.rb +++ b/lib/appwrite/services/presences.rb @@ -51,13 +51,13 @@ def list( def get( presence_id: ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = {} api_headers = { @@ -93,10 +93,7 @@ def upsert( expires_at: nil, metadata: nil ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end @@ -108,6 +105,9 @@ def upsert( raise Appwrite::Exception.new('Missing required parameter: "status"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = { userId: user_id, status: status, @@ -153,10 +153,7 @@ def update( permissions: nil, purge: nil ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end @@ -164,6 +161,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = { userId: user_id, status: status, @@ -197,18 +197,19 @@ def update( def delete( presence_id: ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/project.rb b/lib/appwrite/services/project.rb index 21ff2eb5..e5bc96b9 100644 --- a/lib/appwrite/services/project.rb +++ b/lib/appwrite/services/project.rb @@ -17,6 +17,7 @@ def get() api_headers = { "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', } @client.call( @@ -40,6 +41,7 @@ def delete() api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -53,7 +55,7 @@ def delete() # Update properties of a specific auth method. Use this endpoint to enable or # disable a method in your project. # - # @param [ProjectAuthMethodId] method_id Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone + # @param [ProjectAuthMethodId] method_id Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey # @param [] enabled Auth method status. # # @return [Project] @@ -61,9 +63,6 @@ def update_auth_method( method_id:, enabled: ) - api_path = '/project/auth-methods/{methodId}' - .gsub('{methodId}', method_id) - if method_id.nil? raise Appwrite::Exception.new('Missing required parameter: "methodId"') end @@ -72,6 +71,9 @@ def update_auth_method( raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/auth-methods/{methodId}' + .gsub('{methodId}', method_id) + api_params = { enabled: enabled, } @@ -173,7 +175,7 @@ def create_environment( def get_environment( environment_id: ) - if environment_id.nil? + if environment_id.nil? || environment_id == '' raise Appwrite::Exception.new('Missing required parameter: "environmentId"') end @@ -206,7 +208,7 @@ def update_environment( environment_id:, name: ) - if environment_id.nil? + if environment_id.nil? || environment_id == '' raise Appwrite::Exception.new('Missing required parameter: "environmentId"') end @@ -244,7 +246,7 @@ def update_environment( def delete_environment( environment_id: ) - if environment_id.nil? + if environment_id.nil? || environment_id == '' raise Appwrite::Exception.new('Missing required parameter: "environmentId"') end @@ -312,8 +314,6 @@ def create_ephemeral_key( scopes:, duration: ) - api_path = '/project/keys/ephemeral' - if scopes.nil? raise Appwrite::Exception.new('Missing required parameter: "scopes"') end @@ -322,6 +322,8 @@ def create_ephemeral_key( raise Appwrite::Exception.new('Missing required parameter: "duration"') end + api_path = '/project/keys/ephemeral' + api_params = { scopes: scopes, duration: duration, @@ -350,13 +352,13 @@ def create_ephemeral_key( def get_key( key_id: ) - api_path = '/project/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/project/keys/{keyId}' + .gsub('{keyId}', key_id) + api_params = {} api_headers = { @@ -388,10 +390,7 @@ def update_key( scopes:, expire: nil ) - api_path = '/project/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end @@ -403,6 +402,9 @@ def update_key( raise Appwrite::Exception.new('Missing required parameter: "scopes"') end + api_path = '/project/keys/{keyId}' + .gsub('{keyId}', key_id) + api_params = { name: name, scopes: scopes, @@ -433,18 +435,19 @@ def update_key( def delete_key( key_id: ) - api_path = '/project/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/project/keys/{keyId}' + .gsub('{keyId}', key_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -464,12 +467,12 @@ def delete_key( def update_labels( labels: ) - api_path = '/project/labels' - if labels.nil? raise Appwrite::Exception.new('Missing required parameter: "labels"') end + api_path = '/project/labels' + api_params = { labels: labels, } @@ -532,8 +535,6 @@ def create_mock_phone( number:, otp: ) - api_path = '/project/mock-phones' - if number.nil? raise Appwrite::Exception.new('Missing required parameter: "number"') end @@ -542,6 +543,8 @@ def create_mock_phone( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/project/mock-phones' + api_params = { number: number, otp: otp, @@ -571,13 +574,13 @@ def create_mock_phone( def get_mock_phone( number: ) - api_path = '/project/mock-phones/{number}' - .gsub('{number}', number) - - if number.nil? + if number.nil? || number == '' raise Appwrite::Exception.new('Missing required parameter: "number"') end + api_path = '/project/mock-phones/{number}' + .gsub('{number}', number) + api_params = {} api_headers = { @@ -605,10 +608,7 @@ def update_mock_phone( number:, otp: ) - api_path = '/project/mock-phones/{number}' - .gsub('{number}', number) - - if number.nil? + if number.nil? || number == '' raise Appwrite::Exception.new('Missing required parameter: "number"') end @@ -616,6 +616,9 @@ def update_mock_phone( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/project/mock-phones/{number}' + .gsub('{number}', number) + api_params = { otp: otp, } @@ -644,18 +647,19 @@ def update_mock_phone( def delete_mock_phone( number: ) - api_path = '/project/mock-phones/{number}' - .gsub('{number}', number) - - if number.nil? + if number.nil? || number == '' raise Appwrite::Exception.new('Missing required parameter: "number"') end + api_path = '/project/mock-phones/{number}' + .gsub('{number}', number) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -737,8 +741,6 @@ def update_o_auth2_server( default_scopes: nil, installation_scopes: nil ) - api_path = '/project/oauth2-server' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end @@ -747,6 +749,8 @@ def update_o_auth2_server( raise Appwrite::Exception.new('Missing required parameter: "authorizationUrl"') end + api_path = '/project/oauth2-server' + api_params = { enabled: enabled, authorizationUrl: authorization_url, @@ -1597,23 +1601,23 @@ def update_o_auth2_hugging_face( # # @param [String] client_id 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de # @param [String] client_secret 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled - # @param [Array] prompt Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # @param [Array] prompt Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. # # @return [OAuth2Kakao] def update_o_auth2_kakao( client_id: nil, client_secret: nil, - prompt: nil, - enabled: nil + enabled: nil, + prompt: nil ) api_path = '/project/oauth2/kakao' api_params = { clientId: client_id, clientSecret: client_secret, - prompt: prompt, enabled: enabled, + prompt: prompt, } api_headers = { @@ -2595,13 +2599,13 @@ def update_o_auth2_zoom( def get_o_auth2_provider( provider_id: ) - api_path = '/project/oauth2/{providerId}' - .gsub('{providerId}', provider_id) - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/project/oauth2/{providerId}' + .gsub('{providerId}', provider_id) + api_params = {} api_headers = { @@ -2901,8 +2905,6 @@ def create_android_platform( application_id:, fingerprints: nil ) - api_path = '/project/platforms/android' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -2915,6 +2917,8 @@ def create_android_platform( raise Appwrite::Exception.new('Missing required parameter: "applicationId"') end + api_path = '/project/platforms/android' + api_params = { platformId: platform_id, name: name, @@ -2938,7 +2942,7 @@ def create_android_platform( end # Update an Android platform by its unique ID. Use this endpoint to update - # the platform's name or application ID. + # the platform's name, application ID or signing certificate fingerprints. # # @param [String] platform_id Platform ID. # @param [String] name Platform name. Max length: 128 chars. @@ -2952,10 +2956,7 @@ def update_android_platform( application_id:, fingerprints: nil ) - api_path = '/project/platforms/android/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -2967,6 +2968,9 @@ def update_android_platform( raise Appwrite::Exception.new('Missing required parameter: "applicationId"') end + api_path = '/project/platforms/android/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, applicationId: application_id, @@ -3002,8 +3006,6 @@ def create_apple_platform( name:, bundle_identifier: ) - api_path = '/project/platforms/apple' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3016,6 +3018,8 @@ def create_apple_platform( raise Appwrite::Exception.new('Missing required parameter: "bundleIdentifier"') end + api_path = '/project/platforms/apple' + api_params = { platformId: platform_id, name: name, @@ -3050,10 +3054,7 @@ def update_apple_platform( name:, bundle_identifier: ) - api_path = '/project/platforms/apple/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3065,6 +3066,9 @@ def update_apple_platform( raise Appwrite::Exception.new('Missing required parameter: "bundleIdentifier"') end + api_path = '/project/platforms/apple/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, bundleIdentifier: bundle_identifier, @@ -3099,8 +3103,6 @@ def create_linux_platform( name:, package_name: ) - api_path = '/project/platforms/linux' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3113,6 +3115,8 @@ def create_linux_platform( raise Appwrite::Exception.new('Missing required parameter: "packageName"') end + api_path = '/project/platforms/linux' + api_params = { platformId: platform_id, name: name, @@ -3147,10 +3151,7 @@ def update_linux_platform( name:, package_name: ) - api_path = '/project/platforms/linux/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3162,6 +3163,9 @@ def update_linux_platform( raise Appwrite::Exception.new('Missing required parameter: "packageName"') end + api_path = '/project/platforms/linux/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, packageName: package_name, @@ -3196,8 +3200,6 @@ def create_web_platform( name:, hostname: ) - api_path = '/project/platforms/web' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3210,6 +3212,8 @@ def create_web_platform( raise Appwrite::Exception.new('Missing required parameter: "hostname"') end + api_path = '/project/platforms/web' + api_params = { platformId: platform_id, name: name, @@ -3244,10 +3248,7 @@ def update_web_platform( name:, hostname: ) - api_path = '/project/platforms/web/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3259,6 +3260,9 @@ def update_web_platform( raise Appwrite::Exception.new('Missing required parameter: "hostname"') end + api_path = '/project/platforms/web/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, hostname: hostname, @@ -3293,8 +3297,6 @@ def create_windows_platform( name:, package_identifier_name: ) - api_path = '/project/platforms/windows' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3307,6 +3309,8 @@ def create_windows_platform( raise Appwrite::Exception.new('Missing required parameter: "packageIdentifierName"') end + api_path = '/project/platforms/windows' + api_params = { platformId: platform_id, name: name, @@ -3341,10 +3345,7 @@ def update_windows_platform( name:, package_identifier_name: ) - api_path = '/project/platforms/windows/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3356,6 +3357,9 @@ def update_windows_platform( raise Appwrite::Exception.new('Missing required parameter: "packageIdentifierName"') end + api_path = '/project/platforms/windows/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, packageIdentifierName: package_identifier_name, @@ -3385,13 +3389,13 @@ def update_windows_platform( def get_platform( platform_id: ) - api_path = '/project/platforms/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end + api_path = '/project/platforms/{platformId}' + .gsub('{platformId}', platform_id) + api_params = {} api_headers = { @@ -3447,18 +3451,19 @@ def get_platform( def delete_platform( platform_id: ) - api_path = '/project/platforms/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end + api_path = '/project/platforms/{platformId}' + .gsub('{platformId}', platform_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3509,12 +3514,12 @@ def list_policies( def update_deny_aliased_email_policy( enabled: ) - api_path = '/project/policies/deny-aliased-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-aliased-email' + api_params = { enabled: enabled, } @@ -3543,12 +3548,12 @@ def update_deny_aliased_email_policy( def update_deny_corporate_email_policy( enabled: ) - api_path = '/project/policies/deny-corporate-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-corporate-email' + api_params = { enabled: enabled, } @@ -3577,12 +3582,12 @@ def update_deny_corporate_email_policy( def update_deny_disposable_email_policy( enabled: ) - api_path = '/project/policies/deny-disposable-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-disposable-email' + api_params = { enabled: enabled, } @@ -3611,12 +3616,12 @@ def update_deny_disposable_email_policy( def update_deny_free_email_policy( enabled: ) - api_path = '/project/policies/deny-free-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-free-email' + api_params = { enabled: enabled, } @@ -3772,12 +3777,12 @@ def update_passkey_policy( def update_password_dictionary_policy( enabled: ) - api_path = '/project/policies/password-dictionary' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/password-dictionary' + api_params = { enabled: enabled, } @@ -3813,12 +3818,12 @@ def update_password_dictionary_policy( def update_password_history_policy( total: ) - api_path = '/project/policies/password-history' - if total.nil? raise Appwrite::Exception.new('Missing required parameter: "total"') end + api_path = '/project/policies/password-history' + api_params = { total: total, } @@ -3849,12 +3854,12 @@ def update_password_history_policy( def update_password_personal_data_policy( enabled: ) - api_path = '/project/policies/password-personal-data' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/password-personal-data' + api_params = { enabled: enabled, } @@ -4003,12 +4008,12 @@ def update_password_strength_policy( def update_session_alert_policy( enabled: ) - api_path = '/project/policies/session-alert' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/session-alert' + api_params = { enabled: enabled, } @@ -4037,12 +4042,12 @@ def update_session_alert_policy( def update_session_duration_policy( duration: ) - api_path = '/project/policies/session-duration' - if duration.nil? raise Appwrite::Exception.new('Missing required parameter: "duration"') end + api_path = '/project/policies/session-duration' + api_params = { duration: duration, } @@ -4072,12 +4077,12 @@ def update_session_duration_policy( def update_session_invalidation_policy( enabled: ) - api_path = '/project/policies/session-invalidation' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/session-invalidation' + api_params = { enabled: enabled, } @@ -4106,12 +4111,12 @@ def update_session_invalidation_policy( def update_session_limit_policy( total: ) - api_path = '/project/policies/session-limit' - if total.nil? raise Appwrite::Exception.new('Missing required parameter: "total"') end + api_path = '/project/policies/session-limit' + api_params = { total: total, } @@ -4141,12 +4146,12 @@ def update_session_limit_policy( def update_user_limit_policy( total: ) - api_path = '/project/policies/user-limit' - if total.nil? raise Appwrite::Exception.new('Missing required parameter: "total"') end + api_path = '/project/policies/user-limit' + api_params = { total: total, } @@ -4169,19 +4174,19 @@ def update_user_limit_policy( # Get a policy by its unique ID. This endpoint returns the current # configuration for the requested project policy. # - # @param [ProjectPolicyId] policy_id Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + # @param [ProjectPolicyId] policy_id Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. # # @return [PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordStrength, PolicyPasswordPersonalData, PolicyPasswordPwned, PolicyPasswordRotation, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy, PolicyMfaFactors, PolicyDenyAliasedEmail, PolicyDenyDisposableEmail, PolicyDenyFreeEmail, PolicyDenyCorporateEmail, PolicyPasskey] def get_policy( policy_id: ) - api_path = '/project/policies/{policyId}' - .gsub('{policyId}', policy_id) - if policy_id.nil? raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/project/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -4304,9 +4309,6 @@ def update_protocol( protocol_id:, enabled: ) - api_path = '/project/protocols/{protocolId}' - .gsub('{protocolId}', protocol_id) - if protocol_id.nil? raise Appwrite::Exception.new('Missing required parameter: "protocolId"') end @@ -4315,6 +4317,9 @@ def update_protocol( raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/protocols/{protocolId}' + .gsub('{protocolId}', protocol_id) + api_params = { enabled: enabled, } @@ -4345,9 +4350,6 @@ def update_service( service_id:, enabled: ) - api_path = '/project/services/{serviceId}' - .gsub('{serviceId}', service_id) - if service_id.nil? raise Appwrite::Exception.new('Missing required parameter: "serviceId"') end @@ -4356,6 +4358,9 @@ def update_service( raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/services/{serviceId}' + .gsub('{serviceId}', service_id) + api_params = { enabled: enabled, } @@ -4441,12 +4446,12 @@ def update_smtp( def create_smtp_test( emails: ) - api_path = '/project/smtp/tests' - if emails.nil? raise Appwrite::Exception.new('Missing required parameter: "emails"') end + api_path = '/project/smtp/tests' + api_params = { emails: emails, } @@ -4454,6 +4459,7 @@ def create_smtp_test( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -4500,7 +4506,7 @@ def list_email_templates( # Update a custom email template for the specified locale and type. Use this # endpoint to modify the content of your email templates. # - # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery # @param [ProjectEmailTemplateLocale] locale Custom email template locale. If left empty, the fallback locale (en) will be used. # @param [String] subject Subject of the email template. Can be up to 255 characters. # @param [String] message Plain or HTML body of the email template message. Can be up to 10MB of content. @@ -4520,12 +4526,12 @@ def update_email_template( reply_to_email: nil, reply_to_name: nil ) - api_path = '/project/templates/email' - if template_id.nil? raise Appwrite::Exception.new('Missing required parameter: "templateId"') end + api_path = '/project/templates/email' + api_params = { templateId: template_id, locale: locale, @@ -4556,7 +4562,7 @@ def update_email_template( # endpoint returns the template content, subject, and other configuration # details. # - # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery # @param [ProjectEmailTemplateLocale] locale Custom email template locale. If left empty, the fallback locale (en) will be used. # # @return [EmailTemplate] @@ -4564,13 +4570,13 @@ def get_email_template( template_id:, locale: nil ) - api_path = '/project/templates/email/{templateId}' - .gsub('{templateId}', template_id) - if template_id.nil? raise Appwrite::Exception.new('Missing required parameter: "templateId"') end + api_path = '/project/templates/email/{templateId}' + .gsub('{templateId}', template_id) + api_params = { locale: locale, } @@ -4635,8 +4641,6 @@ def create_variable( value:, secret: nil ) - api_path = '/project/variables' - if variable_id.nil? raise Appwrite::Exception.new('Missing required parameter: "variableId"') end @@ -4649,6 +4653,8 @@ def create_variable( raise Appwrite::Exception.new('Missing required parameter: "value"') end + api_path = '/project/variables' + api_params = { variableId: variable_id, key: key, @@ -4679,13 +4685,13 @@ def create_variable( def get_variable( variable_id: ) - api_path = '/project/variables/{variableId}' - .gsub('{variableId}', variable_id) - - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/project/variables/{variableId}' + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { @@ -4716,13 +4722,13 @@ def update_variable( value: nil, secret: nil ) - api_path = '/project/variables/{variableId}' - .gsub('{variableId}', variable_id) - - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/project/variables/{variableId}' + .gsub('{variableId}', variable_id) + api_params = { key: key, value: value, @@ -4752,18 +4758,19 @@ def update_variable( def delete_variable( variable_id: ) - api_path = '/project/variables/{variableId}' - .gsub('{variableId}', variable_id) - - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/project/variables/{variableId}' + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/proxy.rb b/lib/appwrite/services/proxy.rb index 48d11c6d..ddacf0e4 100644 --- a/lib/appwrite/services/proxy.rb +++ b/lib/appwrite/services/proxy.rb @@ -12,6 +12,8 @@ def initialize(client) # Depending on type, the invalidation purges a single cache tag, a single URL # path, or all cached content for the domain. # + # Domains that route to a function do not support cache invalidation. + # # @param [String] domain Domain name. # @param [InvalidationType] type Type of reference passed. Allowed values are: tag, path, all # @param [String] reference Reference to invalidate. Depending on type this can be: cache tag name (up to 128 characters), URL path (up to 2048 characters). Not required when type is all. @@ -22,8 +24,6 @@ def create_invalidation( type:, reference: nil ) - api_path = '/proxy/invalidations' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -32,6 +32,8 @@ def create_invalidation( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/proxy/invalidations' + api_params = { domain: domain, type: type, @@ -96,12 +98,12 @@ def list_rules( def create_api_rule( domain: ) - api_path = '/proxy/rules/api' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end + api_path = '/proxy/rules/api' + api_params = { domain: domain, } @@ -136,8 +138,6 @@ def create_function_rule( function_id:, branch: nil ) - api_path = '/proxy/rules/function' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -146,6 +146,8 @@ def create_function_rule( raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/proxy/rules/function' + api_params = { domain: domain, functionId: function_id, @@ -187,8 +189,6 @@ def create_redirect_rule( resource_id:, resource_type: ) - api_path = '/proxy/rules/redirect' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -209,6 +209,8 @@ def create_redirect_rule( raise Appwrite::Exception.new('Missing required parameter: "resourceType"') end + api_path = '/proxy/rules/redirect' + api_params = { domain: domain, url: url, @@ -247,8 +249,6 @@ def create_site_rule( site_id:, branch: nil ) - api_path = '/proxy/rules/site' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -257,6 +257,8 @@ def create_site_rule( raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/proxy/rules/site' + api_params = { domain: domain, siteId: site_id, @@ -286,13 +288,13 @@ def create_site_rule( def get_rule( rule_id: ) - api_path = '/proxy/rules/{ruleId}' - .gsub('{ruleId}', rule_id) - - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end + api_path = '/proxy/rules/{ruleId}' + .gsub('{ruleId}', rule_id) + api_params = {} api_headers = { @@ -317,18 +319,19 @@ def get_rule( def delete_rule( rule_id: ) - api_path = '/proxy/rules/{ruleId}' - .gsub('{ruleId}', rule_id) - - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end + api_path = '/proxy/rules/{ruleId}' + .gsub('{ruleId}', rule_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -350,13 +353,13 @@ def delete_rule( def update_rule_status( rule_id: ) - api_path = '/proxy/rules/{ruleId}/status' - .gsub('{ruleId}', rule_id) - - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end + api_path = '/proxy/rules/{ruleId}/status' + .gsub('{ruleId}', rule_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/sites.rb b/lib/appwrite/services/sites.rb index 46a830f2..9a7d793e 100644 --- a/lib/appwrite/services/sites.rb +++ b/lib/appwrite/services/sites.rb @@ -95,8 +95,6 @@ def create( deployment_retention: nil, scopes: nil ) - api_path = '/sites' - if site_id.nil? raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -113,6 +111,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "buildRuntime"') end + api_path = '/sites' + api_params = { siteId: site_id, name: name, @@ -223,13 +223,13 @@ def list_specifications( def get( site_id: ) - api_path = '/sites/{siteId}' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}' + .gsub('{siteId}', site_id) + api_params = {} api_headers = { @@ -300,10 +300,7 @@ def update( deployment_retention: nil, scopes: nil ) - api_path = '/sites/{siteId}' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -315,6 +312,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "framework"') end + api_path = '/sites/{siteId}' + .gsub('{siteId}', site_id) + api_params = { name: name, framework: framework, @@ -364,18 +364,19 @@ def update( def delete( site_id: ) - api_path = '/sites/{siteId}' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}' + .gsub('{siteId}', site_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -397,10 +398,7 @@ def update_site_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployment' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -408,6 +406,9 @@ def update_site_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployment' + .gsub('{siteId}', site_id) + api_params = { deploymentId: deployment_id, } @@ -442,13 +443,13 @@ def list_deployments( search: nil, total: nil ) - api_path = '/sites/{siteId}/deployments' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}/deployments' + .gsub('{siteId}', site_id) + api_params = { queries: queries, search: search, @@ -490,10 +491,7 @@ def create_deployment( activate: nil, on_progress: nil ) - api_path = '/sites/{siteId}/deployments' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -501,6 +499,9 @@ def create_deployment( raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/sites/{siteId}/deployments' + .gsub('{siteId}', site_id) + api_params = { installCommand: install_command, buildCommand: build_command, @@ -525,6 +526,7 @@ def create_deployment( param_name: param_name, id_param_name: id_param_name, on_progress: on_progress, + method: 'POST', response_type: Models::Deployment ) end @@ -543,10 +545,7 @@ def create_duplicate_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/duplicate' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -554,6 +553,9 @@ def create_duplicate_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/duplicate' + .gsub('{siteId}', site_id) + api_params = { deploymentId: deployment_id, } @@ -597,10 +599,7 @@ def create_template_deployment( reference:, activate: nil ) - api_path = '/sites/{siteId}/deployments/template' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -624,6 +623,9 @@ def create_template_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/sites/{siteId}/deployments/template' + .gsub('{siteId}', site_id) + api_params = { repository: repository, owner: owner, @@ -664,10 +666,7 @@ def create_vcs_deployment( reference:, activate: nil ) - api_path = '/sites/{siteId}/deployments/vcs' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -679,6 +678,9 @@ def create_vcs_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/sites/{siteId}/deployments/vcs' + .gsub('{siteId}', site_id) + api_params = { type: type, reference: reference, @@ -710,18 +712,18 @@ def get_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/{deploymentId}' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -748,23 +750,24 @@ def delete_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/{deploymentId}' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -791,18 +794,18 @@ def get_deployment_download( type: nil, token: nil ) - api_path = '/sites/{siteId}/deployments/{deploymentId}/download' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}/download' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = { type: type, token: token, @@ -835,18 +838,18 @@ def update_deployment_status( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/{deploymentId}/status' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}/status' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -877,13 +880,13 @@ def list_logs( queries: nil, total: nil ) - api_path = '/sites/{siteId}/logs' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}/logs' + .gsub('{siteId}', site_id) + api_params = { queries: queries, total: total, @@ -913,18 +916,18 @@ def get_log( site_id:, log_id: ) - api_path = '/sites/{siteId}/logs/{logId}' - .gsub('{siteId}', site_id) - .gsub('{logId}', log_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if log_id.nil? + if log_id.nil? || log_id == '' raise Appwrite::Exception.new('Missing required parameter: "logId"') end + api_path = '/sites/{siteId}/logs/{logId}' + .gsub('{siteId}', site_id) + .gsub('{logId}', log_id) + api_params = {} api_headers = { @@ -951,18 +954,18 @@ def delete_log( site_id:, log_id: ) - api_path = '/sites/{siteId}/logs/{logId}' - .gsub('{siteId}', site_id) - .gsub('{logId}', log_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if log_id.nil? + if log_id.nil? || log_id == '' raise Appwrite::Exception.new('Missing required parameter: "logId"') end + api_path = '/sites/{siteId}/logs/{logId}' + .gsub('{siteId}', site_id) + .gsub('{logId}', log_id) + api_params = {} api_headers = { @@ -991,13 +994,13 @@ def list_variables( queries: nil, total: nil ) - api_path = '/sites/{siteId}/variables' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}/variables' + .gsub('{siteId}', site_id) + api_params = { queries: queries, total: total, @@ -1034,10 +1037,7 @@ def create_variable( value:, secret: nil ) - api_path = '/sites/{siteId}/variables' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -1053,6 +1053,9 @@ def create_variable( raise Appwrite::Exception.new('Missing required parameter: "value"') end + api_path = '/sites/{siteId}/variables' + .gsub('{siteId}', site_id) + api_params = { variableId: variable_id, key: key, @@ -1085,18 +1088,18 @@ def get_variable( site_id:, variable_id: ) - api_path = '/sites/{siteId}/variables/{variableId}' - .gsub('{siteId}', site_id) - .gsub('{variableId}', variable_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/sites/{siteId}/variables/{variableId}' + .gsub('{siteId}', site_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { @@ -1129,18 +1132,18 @@ def update_variable( value: nil, secret: nil ) - api_path = '/sites/{siteId}/variables/{variableId}' - .gsub('{siteId}', site_id) - .gsub('{variableId}', variable_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/sites/{siteId}/variables/{variableId}' + .gsub('{siteId}', site_id) + .gsub('{variableId}', variable_id) + api_params = { key: key, value: value, @@ -1172,23 +1175,24 @@ def delete_variable( site_id:, variable_id: ) - api_path = '/sites/{siteId}/variables/{variableId}' - .gsub('{siteId}', site_id) - .gsub('{variableId}', variable_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/sites/{siteId}/variables/{variableId}' + .gsub('{siteId}', site_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/storage.rb b/lib/appwrite/services/storage.rb index 18389d90..1938edd1 100644 --- a/lib/appwrite/services/storage.rb +++ b/lib/appwrite/services/storage.rb @@ -69,8 +69,6 @@ def create_bucket( antivirus: nil, transformations: nil ) - api_path = '/storage/buckets' - if bucket_id.nil? raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end @@ -79,6 +77,8 @@ def create_bucket( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/storage/buckets' + api_params = { bucketId: bucket_id, name: name, @@ -117,13 +117,13 @@ def create_bucket( def get_bucket( bucket_id: ) - api_path = '/storage/buckets/{bucketId}' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end + api_path = '/storage/buckets/{bucketId}' + .gsub('{bucketId}', bucket_id) + api_params = {} api_headers = { @@ -168,10 +168,7 @@ def update_bucket( antivirus: nil, transformations: nil ) - api_path = '/storage/buckets/{bucketId}' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end @@ -179,6 +176,9 @@ def update_bucket( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/storage/buckets/{bucketId}' + .gsub('{bucketId}', bucket_id) + api_params = { name: name, permissions: permissions, @@ -215,18 +215,19 @@ def update_bucket( def delete_bucket( bucket_id: ) - api_path = '/storage/buckets/{bucketId}' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end + api_path = '/storage/buckets/{bucketId}' + .gsub('{bucketId}', bucket_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -252,13 +253,13 @@ def list_files( search: nil, total: nil ) - api_path = '/storage/buckets/{bucketId}/files' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end + api_path = '/storage/buckets/{bucketId}/files' + .gsub('{bucketId}', bucket_id) + api_params = { queries: queries, search: search, @@ -313,10 +314,7 @@ def create_file( folder: nil, on_progress: nil ) - api_path = '/storage/buckets/{bucketId}/files' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end @@ -328,6 +326,9 @@ def create_file( raise Appwrite::Exception.new('Missing required parameter: "file"') end + api_path = '/storage/buckets/{bucketId}/files' + .gsub('{bucketId}', bucket_id) + api_params = { fileId: file_id, file: file, @@ -351,6 +352,7 @@ def create_file( param_name: param_name, id_param_name: id_param_name, on_progress: on_progress, + method: 'POST', response_type: Models::File ) end @@ -366,18 +368,18 @@ def get_file( bucket_id:, file_id: ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = {} api_headers = { @@ -409,18 +411,18 @@ def update_file( name: nil, permissions: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { name: name, permissions: permissions, @@ -452,23 +454,24 @@ def delete_file( bucket_id:, file_id: ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -493,18 +496,18 @@ def get_file_download( file_id:, token: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}/download' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}/download' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { token: token, } @@ -532,7 +535,7 @@ def get_file_download( # @param [String] file_id File ID # @param [Integer] width Resize preview image width, Pass an integer between 0 to 4000. # @param [Integer] height Resize preview image height, Pass an integer between 0 to 4000. - # @param [ImageGravity] gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right + # @param [ImageGravity] gravity Image crop gravity. Can be one of auto,center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right # @param [Integer] quality Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. # @param [Integer] border_width Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. # @param [String] border_color Preview image border color. Use a valid HEX color, no # is needed for prefix. @@ -560,18 +563,18 @@ def get_file_preview( output: nil, token: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}/preview' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}/preview' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { width: width, height: height, @@ -614,18 +617,18 @@ def get_file_view( file_id:, token: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}/view' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}/view' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { token: token, } diff --git a/lib/appwrite/services/tables_db.rb b/lib/appwrite/services/tables_db.rb index ef709de8..f0ba0f57 100644 --- a/lib/appwrite/services/tables_db.rb +++ b/lib/appwrite/services/tables_db.rb @@ -60,8 +60,6 @@ def create( replicas: nil, sync_mode: nil ) - api_path = '/tablesdb' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -70,6 +68,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/tablesdb' + api_params = { databaseId: database_id, name: name, @@ -95,8 +95,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -187,13 +187,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/tablesdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -222,13 +222,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/tablesdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -257,18 +257,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/tablesdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -289,13 +290,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/tablesdb/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -324,13 +325,13 @@ def create_operations( def get( database_id: ) - api_path = '/tablesdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -365,13 +366,13 @@ def update( replicas: nil, sync_mode: nil ) - api_path = '/tablesdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -404,18 +405,19 @@ def update( def delete( database_id: ) - api_path = '/tablesdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -444,13 +446,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/tablesdb/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -479,13 +481,13 @@ def create_failover( def list_migrations( database_id: ) - api_path = '/tablesdb/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -516,10 +518,7 @@ def create_migration( specification:, auto_cutover: nil ) - api_path = '/tablesdb/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -527,6 +526,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "specification"') end + api_path = '/tablesdb/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { specification: specification, autoCutover: auto_cutover, @@ -557,18 +559,18 @@ def get_migration( database_id:, migration_id: ) - api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' - .gsub('{databaseId}', database_id) - .gsub('{migrationId}', migration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if migration_id.nil? + if migration_id.nil? || migration_id == '' raise Appwrite::Exception.new('Missing required parameter: "migrationId"') end + api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' + .gsub('{databaseId}', database_id) + .gsub('{migrationId}', migration_id) + api_params = {} api_headers = { @@ -596,18 +598,18 @@ def delete_migration( database_id:, migration_id: ) - api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' - .gsub('{databaseId}', database_id) - .gsub('{migrationId}', migration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if migration_id.nil? + if migration_id.nil? || migration_id == '' raise Appwrite::Exception.new('Missing required parameter: "migrationId"') end + api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' + .gsub('{databaseId}', database_id) + .gsub('{migrationId}', migration_id) + api_params = {} api_headers = { @@ -639,18 +641,18 @@ def create_cutover( database_id:, migration_id: ) - api_path = '/tablesdb/{databaseId}/migrations/{migrationId}/cutovers' - .gsub('{databaseId}', database_id) - .gsub('{migrationId}', migration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if migration_id.nil? + if migration_id.nil? || migration_id == '' raise Appwrite::Exception.new('Missing required parameter: "migrationId"') end + api_path = '/tablesdb/{databaseId}/migrations/{migrationId}/cutovers' + .gsub('{databaseId}', database_id) + .gsub('{migrationId}', migration_id) + api_params = {} api_headers = { @@ -685,13 +687,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/tablesdb/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -721,13 +723,13 @@ def list_operations( def get_replicas( database_id: ) - api_path = '/tablesdb/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -754,13 +756,13 @@ def get_replicas( def get_status( database_id: ) - api_path = '/tablesdb/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -792,13 +794,13 @@ def list_tables( search: nil, total: nil ) - api_path = '/tablesdb/{databaseId}/tables' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/tables' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -831,7 +833,7 @@ def list_tables( # @param [] row_security Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] enabled Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. # @param [Array] columns Array of column definitions to create. Each column should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. - # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). # # @return [Table] def create_table( @@ -844,10 +846,7 @@ def create_table( columns: nil, indexes: nil ) - api_path = '/tablesdb/{databaseId}/tables' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -859,6 +858,9 @@ def create_table( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/tablesdb/{databaseId}/tables' + .gsub('{databaseId}', database_id) + api_params = { tableId: table_id, name: name, @@ -895,18 +897,18 @@ def get_table( database_id:, table_id: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = {} api_headers = { @@ -943,18 +945,18 @@ def update_table( enabled: nil, purge: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { name: name, permissions: permissions, @@ -989,23 +991,24 @@ def delete_table( database_id:, table_id: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1030,18 +1033,18 @@ def list_columns( queries: nil, total: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, total: total, @@ -1085,15 +1088,11 @@ def create_big_int_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1105,6 +1104,10 @@ def create_big_int_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1153,20 +1156,15 @@ def update_big_int_column( max: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1178,6 +1176,11 @@ def update_big_int_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1220,15 +1223,11 @@ def create_boolean_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1240,6 +1239,10 @@ def create_boolean_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1281,20 +1284,15 @@ def update_boolean_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1306,6 +1304,11 @@ def update_boolean_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1345,15 +1348,11 @@ def create_datetime_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1365,6 +1364,10 @@ def create_datetime_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1406,20 +1409,15 @@ def update_datetime_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1431,6 +1429,11 @@ def update_datetime_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1471,15 +1474,11 @@ def create_email_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1491,6 +1490,10 @@ def create_email_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1533,20 +1536,15 @@ def update_email_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1558,6 +1556,11 @@ def update_email_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1600,15 +1603,11 @@ def create_enum_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1624,6 +1623,10 @@ def create_enum_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, elements: elements, @@ -1669,20 +1672,15 @@ def update_enum_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1698,6 +1696,11 @@ def update_enum_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { elements: elements, required: required, @@ -1744,15 +1747,11 @@ def create_float_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1764,6 +1763,10 @@ def create_float_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1812,20 +1815,15 @@ def update_float_column( max: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1837,6 +1835,11 @@ def update_float_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1884,15 +1887,11 @@ def create_integer_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1904,6 +1903,10 @@ def create_integer_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1952,20 +1955,15 @@ def update_integer_column( max: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1977,6 +1975,11 @@ def update_integer_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -2019,15 +2022,11 @@ def create_ip_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2039,6 +2038,10 @@ def create_ip_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2081,20 +2084,15 @@ def update_ip_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2106,6 +2104,11 @@ def update_ip_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2143,15 +2146,11 @@ def create_line_column( required:, default: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2163,6 +2162,10 @@ def create_line_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2203,20 +2206,15 @@ def update_line_column( default: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2224,6 +2222,11 @@ def update_line_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2266,15 +2269,11 @@ def create_longtext_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2286,6 +2285,10 @@ def create_longtext_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2329,20 +2332,15 @@ def update_longtext_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2354,6 +2352,11 @@ def update_longtext_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2396,15 +2399,11 @@ def create_mediumtext_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2416,6 +2415,10 @@ def create_mediumtext_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2459,20 +2462,15 @@ def update_mediumtext_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2484,6 +2482,11 @@ def update_mediumtext_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2521,15 +2524,11 @@ def create_point_column( required:, default: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2541,6 +2540,10 @@ def create_point_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2581,20 +2584,15 @@ def update_point_column( default: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2602,6 +2600,11 @@ def update_point_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2639,15 +2642,11 @@ def create_polygon_column( required:, default: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2659,6 +2658,10 @@ def create_polygon_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2699,20 +2702,15 @@ def update_polygon_column( default: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2720,6 +2718,11 @@ def update_polygon_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2765,15 +2768,11 @@ def create_relationship_column( two_way_key: nil, on_delete: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2785,6 +2784,10 @@ def create_relationship_column( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { relatedTableId: related_table_id, type: type, @@ -2809,41 +2812,92 @@ def create_relationship_column( ) end - # - # @deprecated This API has been deprecated since 1.9.0. Please use `TablesDB.createTextColumn` instead. - # - # Create a string column. + # Update relationship column. [Learn more about relationship + # columns](https://appwrite.io/docs/databases-relationships#relationship-columns). # # # @param [String] database_id Database ID. - # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] table_id Table ID. # @param [String] key Column Key. - # @param [Integer] size Column size for text columns, in number of characters. - # @param [] required Is column required? - # @param [String] default Default value for column when not provided. Cannot be set when column is required. - # @param [] array Is column an array? - # @param [] encrypt Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + # @param [RelationMutate] on_delete Delete constraint. Possible values are: cascade, restrict, setNull. + # @param [String] new_key New Column Key. # - # @return [ColumnString] - def create_string_column( + # @return [ColumnRelationship] + def update_relationship_column( database_id:, table_id:, key:, - size:, - required:, - default: nil, - array: nil, - encrypt: nil + on_delete: nil, + new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string' - .gsub('{databaseId}', database_id) + if database_id.nil? || database_id == '' + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if table_id.nil? || table_id == '' + raise Appwrite::Exception.new('Missing required parameter: "tableId"') + end + + if key.nil? || key == '' + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key}' + .gsub('{databaseId}', database_id) .gsub('{tableId}', table_id) + .gsub('{key}', key) - if database_id.nil? + api_params = { + onDelete: on_delete, + newKey: new_key, + } + + 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::ColumnRelationship + ) + end + + # + # @deprecated This API has been deprecated since 1.9.0. Please use `TablesDB.createTextColumn` instead. + # + # Create a string column. + # + # + # @param [String] database_id Database ID. + # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] key Column Key. + # @param [Integer] size Column size for text columns, in number of characters. + # @param [] required Is column required? + # @param [String] default Default value for column when not provided. Cannot be set when column is required. + # @param [] array Is column an array? + # @param [] encrypt Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + # + # @return [ColumnString] + def create_string_column( + database_id:, + table_id:, + key:, + size:, + required:, + default: nil, + array: nil, + encrypt: nil + ) + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2859,6 +2913,10 @@ def create_string_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, size: size, @@ -2908,20 +2966,15 @@ def update_string_column( size: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2933,6 +2986,11 @@ def update_string_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2976,15 +3034,11 @@ def create_text_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2996,6 +3050,10 @@ def create_text_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -3039,20 +3097,15 @@ def update_text_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3064,6 +3117,11 @@ def update_text_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3104,15 +3162,11 @@ def create_url_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3124,6 +3178,10 @@ def create_url_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -3166,20 +3224,15 @@ def update_url_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3191,6 +3244,11 @@ def update_url_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3235,15 +3293,11 @@ def create_varchar_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3259,6 +3313,10 @@ def create_varchar_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, size: size, @@ -3305,20 +3363,15 @@ def update_varchar_column( size: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3330,6 +3383,11 @@ def update_varchar_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3358,29 +3416,29 @@ def update_varchar_column( # @param [String] table_id Table ID. # @param [String] key Column Key. # - # @return [ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnString] + # @return [ColumnBoolean, ColumnBigint, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnPoint, ColumnLine, ColumnPolygon, ColumnVarchar, ColumnText, ColumnMediumtext, ColumnLongtext, ColumnString] def get_column( database_id:, table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -3424,6 +3482,11 @@ def get_column( return Models::ColumnBoolean.from(map: response) end + if response['type'] == 'bigint' + + return Models::ColumnBigint.from(map: response) + end + if response['type'] == 'integer' return Models::ColumnInteger.from(map: response) @@ -3444,6 +3507,41 @@ def get_column( return Models::ColumnRelationship.from(map: response) end + if response['type'] == 'point' + + return Models::ColumnPoint.from(map: response) + end + + if response['type'] == 'linestring' + + return Models::ColumnLine.from(map: response) + end + + if response['type'] == 'polygon' + + return Models::ColumnPolygon.from(map: response) + end + + if response['type'] == 'varchar' + + return Models::ColumnVarchar.from(map: response) + end + + if response['type'] == 'text' + + return Models::ColumnText.from(map: response) + end + + if response['type'] == 'mediumtext' + + return Models::ColumnMediumtext.from(map: response) + end + + if response['type'] == 'longtext' + + return Models::ColumnLongtext.from(map: response) + end + if response['type'] == 'string' return Models::ColumnString.from(map: response) @@ -3464,77 +3562,24 @@ def delete_column( table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end - api_params = {} - - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), - "content-type": 'application/json', - } - - @client.call( - method: 'DELETE', - path: api_path, - headers: api_headers, - params: api_params, - ) - end - - # Update relationship column. [Learn more about relationship - # columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - # - # - # @param [String] database_id Database ID. - # @param [String] table_id Table ID. - # @param [String] key Column Key. - # @param [RelationMutate] on_delete Delete constraint. Possible values are: cascade, restrict, setNull. - # @param [String] new_key New Column Key. - # - # @return [ColumnRelationship] - def update_relationship_column( - database_id:, - table_id:, - key:, - on_delete: nil, - new_key: nil - ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship' + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' .gsub('{databaseId}', database_id) .gsub('{tableId}', table_id) .gsub('{key}', key) - if database_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "databaseId"') - end - - if table_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "tableId"') - end - - if key.nil? - raise Appwrite::Exception.new('Missing required parameter: "key"') - end - - api_params = { - onDelete: on_delete, - newKey: new_key, - } + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -3543,11 +3588,10 @@ def update_relationship_column( } @client.call( - method: 'PATCH', + method: 'DELETE', path: api_path, headers: api_headers, params: api_params, - response_type: Models::ColumnRelationship ) end @@ -3565,18 +3609,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, total: total, @@ -3598,7 +3642,9 @@ def list_indexes( # Creates an index on the columns listed. Your index should include all the # columns you will query in a single request. - # Type can be `key`, `fulltext`, or `unique`. + # Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` + # is only available on PostgreSQL and lets `contains`, `startsWith`, and + # `endsWith` queries on string columns use an index. # # @param [String] database_id Database ID. # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3618,15 +3664,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3642,6 +3684,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "columns"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, type: type, @@ -3677,23 +3723,23 @@ def get_index( table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -3722,28 +3768,29 @@ def delete_index( table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3773,18 +3820,18 @@ def list_rows( total: nil, ttl: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3827,15 +3874,11 @@ def create_row( permissions: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3847,6 +3890,10 @@ def create_row( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { rowId: row_id, data: data, @@ -3886,15 +3933,11 @@ def create_rows( rows:, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3902,6 +3945,10 @@ def create_rows( raise Appwrite::Exception.new('Missing required parameter: "rows"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { rows: rows, transactionId: transaction_id, @@ -3940,15 +3987,11 @@ def upsert_rows( rows:, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3956,6 +3999,10 @@ def upsert_rows( raise Appwrite::Exception.new('Missing required parameter: "rows"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { rows: rows, transactionId: transaction_id, @@ -3993,18 +4040,18 @@ def update_rows( queries: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { data: data, queries: queries, @@ -4041,18 +4088,18 @@ def delete_rows( queries: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -4090,23 +4137,23 @@ def get_row( queries: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -4147,23 +4194,23 @@ def upsert_row( permissions: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { data: data, permissions: permissions, @@ -4204,23 +4251,23 @@ def update_row( permissions: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { data: data, permissions: permissions, @@ -4256,23 +4303,23 @@ def delete_row( row_id:, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { transactionId: transaction_id, } @@ -4280,6 +4327,7 @@ def delete_row( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -4310,28 +4358,28 @@ def decrement_row_column( min: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - .gsub('{column}', column) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end - if column.nil? + if column.nil? || column == '' raise Appwrite::Exception.new('Missing required parameter: "column"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + .gsub('{column}', column) + api_params = { value: value, min: min, @@ -4373,28 +4421,28 @@ def increment_row_column( max: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - .gsub('{column}', column) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end - if column.nil? + if column.nil? || column == '' raise Appwrite::Exception.new('Missing required parameter: "column"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + .gsub('{column}', column) + api_params = { value: value, max: max, diff --git a/lib/appwrite/services/teams.rb b/lib/appwrite/services/teams.rb index 8e19b572..71a2bc7e 100644 --- a/lib/appwrite/services/teams.rb +++ b/lib/appwrite/services/teams.rb @@ -47,7 +47,7 @@ def list( # # @param [String] team_id Team 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 Team name. Max length: 128 chars. - # @param [Array] roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + # @param [Array] roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long. # # @return [Team] def create( @@ -55,8 +55,6 @@ def create( name:, roles: nil ) - api_path = '/teams' - if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -65,6 +63,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/teams' + api_params = { teamId: team_id, name: name, @@ -94,13 +94,13 @@ def create( def get( team_id: ) - api_path = '/teams/{teamId}' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}' + .gsub('{teamId}', team_id) + api_params = {} api_headers = { @@ -127,10 +127,7 @@ def update_name( team_id:, name: ) - api_path = '/teams/{teamId}' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -138,6 +135,9 @@ def update_name( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/teams/{teamId}' + .gsub('{teamId}', team_id) + api_params = { name: name, } @@ -166,18 +166,19 @@ def update_name( def delete( team_id: ) - api_path = '/teams/{teamId}' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}' + .gsub('{teamId}', team_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -200,13 +201,13 @@ def list_installations( queries: nil, total: nil ) - api_path = '/teams/{teamId}/installations' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}/installations' + .gsub('{teamId}', team_id) + api_params = { queries: queries, total: total, @@ -241,10 +242,7 @@ def create_installation( app_id:, authorization_details: nil ) - api_path = '/teams/{teamId}/installations' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -252,6 +250,9 @@ def create_installation( raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/teams/{teamId}/installations' + .gsub('{teamId}', team_id) + api_params = { appId: app_id, authorizationDetails: authorization_details, @@ -283,18 +284,18 @@ 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? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/teams/{teamId}/installations/{installationId}' + .gsub('{teamId}', team_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -326,18 +327,18 @@ def update_installation( installation_id:, authorization_details: nil ) - api_path = '/teams/{teamId}/installations/{installationId}' - .gsub('{teamId}', team_id) - .gsub('{installationId}', installation_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/teams/{teamId}/installations/{installationId}' + .gsub('{teamId}', team_id) + .gsub('{installationId}', installation_id) + api_params = { authorizationDetails: authorization_details, } @@ -369,18 +370,18 @@ 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? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/teams/{teamId}/installations/{installationId}' + .gsub('{teamId}', team_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -413,13 +414,13 @@ def list_memberships( search: nil, total: nil ) - api_path = '/teams/{teamId}/memberships' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}/memberships' + .gsub('{teamId}', team_id) + api_params = { queries: queries, search: search, @@ -482,10 +483,7 @@ def create_membership( name: nil, membership_id: nil ) - api_path = '/teams/{teamId}/memberships' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -493,6 +491,9 @@ def create_membership( raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/teams/{teamId}/memberships' + .gsub('{teamId}', team_id) + api_params = { email: email, userId: user_id, @@ -530,18 +531,18 @@ def get_membership( team_id:, membership_id: ) - api_path = '/teams/{teamId}/memberships/{membershipId}' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/teams/{teamId}/memberships/{membershipId}' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { @@ -573,15 +574,11 @@ def update_membership( membership_id:, roles: ) - api_path = '/teams/{teamId}/memberships/{membershipId}' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end @@ -589,6 +586,10 @@ def update_membership( raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/teams/{teamId}/memberships/{membershipId}' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = { roles: roles, } @@ -620,23 +621,24 @@ def delete_membership( team_id:, membership_id: ) - api_path = '/teams/{teamId}/memberships/{membershipId}' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/teams/{teamId}/memberships/{membershipId}' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -667,15 +669,11 @@ def update_membership_status( user_id:, secret: ) - api_path = '/teams/{teamId}/memberships/{membershipId}/status' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end @@ -687,6 +685,10 @@ def update_membership_status( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/teams/{teamId}/memberships/{membershipId}/status' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = { userId: user_id, secret: secret, @@ -717,13 +719,13 @@ def update_membership_status( def get_prefs( team_id: ) - api_path = '/teams/{teamId}/prefs' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}/prefs' + .gsub('{teamId}', team_id) + api_params = {} api_headers = { @@ -752,10 +754,7 @@ def update_prefs( team_id:, prefs: ) - api_path = '/teams/{teamId}/prefs' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -763,6 +762,9 @@ def update_prefs( raise Appwrite::Exception.new('Missing required parameter: "prefs"') end + api_path = '/teams/{teamId}/prefs' + .gsub('{teamId}', team_id) + api_params = { prefs: prefs, } diff --git a/lib/appwrite/services/tokens.rb b/lib/appwrite/services/tokens.rb index 72ba9710..0e18e7b5 100644 --- a/lib/appwrite/services/tokens.rb +++ b/lib/appwrite/services/tokens.rb @@ -21,18 +21,18 @@ def list( queries: nil, total: nil ) - api_path = '/tokens/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/tokens/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { queries: queries, total: total, @@ -65,18 +65,18 @@ def create_file_token( file_id:, expire: nil ) - api_path = '/tokens/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/tokens/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { expire: expire, } @@ -104,13 +104,13 @@ def create_file_token( def get( token_id: ) - api_path = '/tokens/{tokenId}' - .gsub('{tokenId}', token_id) - - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/tokens/{tokenId}' + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { @@ -138,13 +138,13 @@ def update( token_id:, expire: nil ) - api_path = '/tokens/{tokenId}' - .gsub('{tokenId}', token_id) - - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/tokens/{tokenId}' + .gsub('{tokenId}', token_id) + api_params = { expire: expire, } @@ -172,18 +172,19 @@ def update( def delete( token_id: ) - api_path = '/tokens/{tokenId}' - .gsub('{tokenId}', token_id) - - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/tokens/{tokenId}' + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/users.rb b/lib/appwrite/services/users.rb index aefa1b2a..dbcf3e56 100644 --- a/lib/appwrite/services/users.rb +++ b/lib/appwrite/services/users.rb @@ -9,7 +9,7 @@ def initialize(client) # Get a list of all the project's users. You can use the query params to # filter your results. # - # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels, impersonator, accessedAt + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, passwordPwned, labels, impersonator, accessedAt # @param [String] search Search term to filter your list results. Max length: 256 chars. # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # @@ -57,12 +57,12 @@ def create( password: nil, name: nil ) - api_path = '/users' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users' + api_params = { userId: user_id, email: email, @@ -103,8 +103,6 @@ def create_argon2_user( password:, name: nil ) - api_path = '/users/argon2' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -117,6 +115,8 @@ def create_argon2_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/argon2' + api_params = { userId: user_id, email: email, @@ -156,8 +156,6 @@ def create_bcrypt_user( password:, name: nil ) - api_path = '/users/bcrypt' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -170,6 +168,8 @@ def create_bcrypt_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/bcrypt' + api_params = { userId: user_id, email: email, @@ -234,18 +234,19 @@ def list_identities( def delete_identity( identity_id: ) - api_path = '/users/identities/{identityId}' - .gsub('{identityId}', identity_id) - - if identity_id.nil? + if identity_id.nil? || identity_id == '' raise Appwrite::Exception.new('Missing required parameter: "identityId"') end + api_path = '/users/identities/{identityId}' + .gsub('{identityId}', identity_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -273,8 +274,6 @@ def create_md5_user( password:, name: nil ) - api_path = '/users/md5' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -287,6 +286,8 @@ def create_md5_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/md5' + api_params = { userId: user_id, email: email, @@ -326,8 +327,6 @@ def create_ph_pass_user( password:, name: nil ) - api_path = '/users/phpass' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -340,6 +339,8 @@ def create_ph_pass_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/phpass' + api_params = { userId: user_id, email: email, @@ -389,8 +390,6 @@ def create_scrypt_user( password_length:, name: nil ) - api_path = '/users/scrypt' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -423,6 +422,8 @@ def create_scrypt_user( raise Appwrite::Exception.new('Missing required parameter: "passwordLength"') end + api_path = '/users/scrypt' + api_params = { userId: user_id, email: email, @@ -474,8 +475,6 @@ def create_scrypt_modified_user( password_signer_key:, name: nil ) - api_path = '/users/scrypt-modified' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -500,6 +499,8 @@ def create_scrypt_modified_user( raise Appwrite::Exception.new('Missing required parameter: "passwordSignerKey"') end + api_path = '/users/scrypt-modified' + api_params = { userId: user_id, email: email, @@ -544,8 +545,6 @@ def create_sha_user( password_version: nil, name: nil ) - api_path = '/users/sha' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -558,6 +557,8 @@ def create_sha_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/sha' + api_params = { userId: user_id, email: email, @@ -589,13 +590,13 @@ def create_sha_user( def get( user_id: ) - api_path = '/users/{userId}' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -625,18 +626,19 @@ def get( def delete( user_id: ) - api_path = '/users/{userId}' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}' + .gsub('{userId}', user_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -657,10 +659,7 @@ def update_email( user_id:, email: ) - api_path = '/users/{userId}/email' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -668,6 +667,9 @@ def update_email( raise Appwrite::Exception.new('Missing required parameter: "email"') end + api_path = '/users/{userId}/email' + .gsub('{userId}', user_id) + api_params = { email: email, } @@ -691,7 +693,10 @@ def update_email( # impersonation headers are used, the request runs as the target user for API # behavior, while internal audit logs still attribute the action to the # original impersonator and store the impersonated target details only in - # internal audit payload data. + # internal audit payload data. Account endpoints are read-only while + # impersonating: they report the target's account, and anything that would + # change it is refused, so an impersonator cannot alter the target's + # credentials or delete their account. # # # @param [String] user_id User ID. @@ -702,10 +707,7 @@ def update_impersonator( user_id:, impersonator: ) - api_path = '/users/{userId}/impersonator' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -713,6 +715,9 @@ def update_impersonator( raise Appwrite::Exception.new('Missing required parameter: "impersonator"') end + api_path = '/users/{userId}/impersonator' + .gsub('{userId}', user_id) + api_params = { impersonator: impersonator, } @@ -746,13 +751,13 @@ def create_jwt( session_id: nil, duration: nil ) - api_path = '/users/{userId}/jwts' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/jwts' + .gsub('{userId}', user_id) + api_params = { sessionId: session_id, duration: duration, @@ -788,10 +793,7 @@ def update_labels( user_id:, labels: ) - api_path = '/users/{userId}/labels' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -799,6 +801,9 @@ def update_labels( raise Appwrite::Exception.new('Missing required parameter: "labels"') end + api_path = '/users/{userId}/labels' + .gsub('{userId}', user_id) + api_params = { labels: labels, } @@ -818,44 +823,6 @@ def update_labels( ) end - # Get the user activity logs list by its unique ID. - # - # @param [String] user_id User 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). Only supported methods are limit and offset - # @param [] total When set to false, the total count returned will be 0 and will not be calculated. - # - # @return [LogList] - def list_logs( - user_id:, - queries: nil, - total: nil - ) - api_path = '/users/{userId}/logs' - .gsub('{userId}', user_id) - - if user_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "userId"') - 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::LogList - ) - end - # Get the user membership list by its unique ID. # # @param [String] user_id User ID. @@ -870,13 +837,13 @@ def list_memberships( search: nil, total: nil ) - api_path = '/users/{userId}/memberships' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/memberships' + .gsub('{userId}', user_id) + api_params = { queries: queries, search: search, @@ -907,10 +874,7 @@ def update_mfa( user_id:, mfa: ) - api_path = '/users/{userId}/mfa' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -918,6 +882,9 @@ def update_mfa( raise Appwrite::Exception.new('Missing required parameter: "mfa"') end + api_path = '/users/{userId}/mfa' + .gsub('{userId}', user_id) + api_params = { mfa: mfa, } @@ -947,11 +914,7 @@ def delete_mfa_authenticator( user_id:, type: ) - api_path = '/users/{userId}/mfa/authenticators/{type}' - .gsub('{userId}', user_id) - .gsub('{type}', type) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -959,11 +922,16 @@ def delete_mfa_authenticator( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/users/{userId}/mfa/authenticators/{type}' + .gsub('{userId}', user_id) + .gsub('{type}', type) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -985,18 +953,18 @@ def get_mfa_challenge( user_id:, challenge_id: ) - api_path = '/users/{userId}/mfa/challenges/{challengeId}' - .gsub('{userId}', user_id) - .gsub('{challengeId}', challenge_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if challenge_id.nil? + if challenge_id.nil? || challenge_id == '' raise Appwrite::Exception.new('Missing required parameter: "challengeId"') end + api_path = '/users/{userId}/mfa/challenges/{challengeId}' + .gsub('{userId}', user_id) + .gsub('{challengeId}', challenge_id) + api_params = {} api_headers = { @@ -1021,13 +989,13 @@ def get_mfa_challenge( def list_mfa_factors( user_id: ) - api_path = '/users/{userId}/mfa/factors' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/factors' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1055,13 +1023,13 @@ def list_mfa_factors( def get_mfa_recovery_codes( user_id: ) - api_path = '/users/{userId}/mfa/recovery-codes' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/recovery-codes' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1089,13 +1057,13 @@ def get_mfa_recovery_codes( def update_mfa_recovery_codes( user_id: ) - api_path = '/users/{userId}/mfa/recovery-codes' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/recovery-codes' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1124,13 +1092,13 @@ def update_mfa_recovery_codes( def create_mfa_recovery_codes( user_id: ) - api_path = '/users/{userId}/mfa/recovery-codes' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/recovery-codes' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1158,10 +1126,7 @@ def update_name( user_id:, name: ) - api_path = '/users/{userId}/name' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1169,6 +1134,9 @@ def update_name( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/users/{userId}/name' + .gsub('{userId}', user_id) + api_params = { name: name, } @@ -1360,10 +1328,7 @@ def update_password( user_id:, password: ) - api_path = '/users/{userId}/password' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1371,6 +1336,9 @@ def update_password( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/{userId}/password' + .gsub('{userId}', user_id) + api_params = { password: password, } @@ -1400,10 +1368,7 @@ def update_phone( user_id:, number: ) - api_path = '/users/{userId}/phone' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1411,6 +1376,9 @@ def update_phone( raise Appwrite::Exception.new('Missing required parameter: "number"') end + api_path = '/users/{userId}/phone' + .gsub('{userId}', user_id) + api_params = { number: number, } @@ -1438,13 +1406,13 @@ def update_phone( def get_prefs( user_id: ) - api_path = '/users/{userId}/prefs' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/prefs' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1473,10 +1441,7 @@ def update_prefs( user_id:, prefs: ) - api_path = '/users/{userId}/prefs' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1484,6 +1449,9 @@ def update_prefs( raise Appwrite::Exception.new('Missing required parameter: "prefs"') end + api_path = '/users/{userId}/prefs' + .gsub('{userId}', user_id) + api_params = { prefs: prefs, } @@ -1513,13 +1481,13 @@ def list_sessions( user_id:, total: nil ) - api_path = '/users/{userId}/sessions' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/sessions' + .gsub('{userId}', user_id) + api_params = { total: total, } @@ -1551,13 +1519,13 @@ def list_sessions( def create_session( user_id: ) - api_path = '/users/{userId}/sessions' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/sessions' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1583,18 +1551,19 @@ def create_session( def delete_sessions( user_id: ) - api_path = '/users/{userId}/sessions' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/sessions' + .gsub('{userId}', user_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1615,23 +1584,24 @@ def delete_session( user_id:, session_id: ) - api_path = '/users/{userId}/sessions/{sessionId}' - .gsub('{userId}', user_id) - .gsub('{sessionId}', session_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/users/{userId}/sessions/{sessionId}' + .gsub('{userId}', user_id) + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1653,10 +1623,7 @@ def update_status( user_id:, status: ) - api_path = '/users/{userId}/status' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1664,6 +1631,9 @@ def update_status( raise Appwrite::Exception.new('Missing required parameter: "status"') end + api_path = '/users/{userId}/status' + .gsub('{userId}', user_id) + api_params = { status: status, } @@ -1695,13 +1665,13 @@ def list_targets( queries: nil, total: nil ) - api_path = '/users/{userId}/targets' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/targets' + .gsub('{userId}', user_id) + api_params = { queries: queries, total: total, @@ -1739,10 +1709,7 @@ def create_target( provider_id: nil, name: nil ) - api_path = '/users/{userId}/targets' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1758,6 +1725,9 @@ def create_target( raise Appwrite::Exception.new('Missing required parameter: "identifier"') end + api_path = '/users/{userId}/targets' + .gsub('{userId}', user_id) + api_params = { targetId: target_id, providerType: provider_type, @@ -1791,18 +1761,18 @@ def get_target( user_id:, target_id: ) - api_path = '/users/{userId}/targets/{targetId}' - .gsub('{userId}', user_id) - .gsub('{targetId}', target_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if target_id.nil? + if target_id.nil? || target_id == '' raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/users/{userId}/targets/{targetId}' + .gsub('{userId}', user_id) + .gsub('{targetId}', target_id) + api_params = {} api_headers = { @@ -1835,18 +1805,18 @@ def update_target( provider_id: nil, name: nil ) - api_path = '/users/{userId}/targets/{targetId}' - .gsub('{userId}', user_id) - .gsub('{targetId}', target_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if target_id.nil? + if target_id.nil? || target_id == '' raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/users/{userId}/targets/{targetId}' + .gsub('{userId}', user_id) + .gsub('{targetId}', target_id) + api_params = { identifier: identifier, providerId: provider_id, @@ -1878,23 +1848,24 @@ def delete_target( user_id:, target_id: ) - api_path = '/users/{userId}/targets/{targetId}' - .gsub('{userId}', user_id) - .gsub('{targetId}', target_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if target_id.nil? + if target_id.nil? || target_id == '' raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/users/{userId}/targets/{targetId}' + .gsub('{userId}', user_id) + .gsub('{targetId}', target_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1921,13 +1892,13 @@ def create_token( length: nil, expire: nil ) - api_path = '/users/{userId}/tokens' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/tokens' + .gsub('{userId}', user_id) + api_params = { length: length, expire: expire, @@ -1958,10 +1929,7 @@ def update_email_verification( user_id:, email_verification: ) - api_path = '/users/{userId}/verification' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1969,6 +1937,9 @@ def update_email_verification( raise Appwrite::Exception.new('Missing required parameter: "emailVerification"') end + api_path = '/users/{userId}/verification' + .gsub('{userId}', user_id) + api_params = { emailVerification: email_verification, } @@ -1998,10 +1969,7 @@ def update_phone_verification( user_id:, phone_verification: ) - api_path = '/users/{userId}/verification/phone' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2009,6 +1977,9 @@ def update_phone_verification( raise Appwrite::Exception.new('Missing required parameter: "phoneVerification"') end + api_path = '/users/{userId}/verification/phone' + .gsub('{userId}', user_id) + api_params = { phoneVerification: phone_verification, } diff --git a/lib/appwrite/services/vectors_db.rb b/lib/appwrite/services/vectors_db.rb index 5d8fe64e..a3440518 100644 --- a/lib/appwrite/services/vectors_db.rb +++ b/lib/appwrite/services/vectors_db.rb @@ -57,8 +57,6 @@ def create( replicas: nil, sync_mode: nil ) - api_path = '/vectorsdb' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -67,6 +65,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/vectorsdb' + api_params = { databaseId: database_id, name: name, @@ -92,8 +92,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -184,13 +184,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/vectorsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/vectorsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -254,18 +254,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/vectorsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -286,13 +287,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/vectorsdb/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -321,13 +322,13 @@ def create_operations( def get( database_id: ) - api_path = '/vectorsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -362,10 +363,7 @@ def update( replicas: nil, sync_mode: nil ) - api_path = '/vectorsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -373,6 +371,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/vectorsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -405,18 +406,19 @@ def update( def delete( database_id: ) - api_path = '/vectorsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -442,13 +444,13 @@ def list_collections( search: nil, total: nil ) - api_path = '/vectorsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -492,10 +494,7 @@ def create_collection( document_security: nil, enabled: nil ) - api_path = '/vectorsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -511,6 +510,9 @@ def create_collection( raise Appwrite::Exception.new('Missing required parameter: "dimension"') end + api_path = '/vectorsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { collectionId: collection_id, name: name, @@ -546,18 +548,18 @@ def get_collection( database_id:, collection_id: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { @@ -594,15 +596,11 @@ def update_collection( document_security: nil, enabled: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -610,6 +608,10 @@ def update_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { name: name, dimension: dimension, @@ -644,23 +646,24 @@ def delete_collection( database_id:, collection_id: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -690,18 +693,18 @@ def list_documents( total: nil, ttl: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -744,15 +747,11 @@ def create_document( permissions: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -764,6 +763,10 @@ def create_document( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documentId: document_id, data: data, @@ -803,15 +806,11 @@ def create_documents( documents:, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -819,6 +818,10 @@ def create_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -857,15 +860,11 @@ def upsert_documents( documents:, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -873,6 +872,10 @@ def upsert_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -911,18 +914,18 @@ def update_documents( queries: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { data: data, queries: queries, @@ -959,18 +962,18 @@ def delete_documents( queries: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1013,18 +1016,18 @@ def create_query( total: nil, ttl: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/query' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/query' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1064,23 +1067,23 @@ def get_document( queries: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1121,23 +1124,23 @@ def upsert_document( permissions: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1178,23 +1181,23 @@ def update_document( permissions: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1230,23 +1233,23 @@ def delete_document( document_id:, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { transactionId: transaction_id, } @@ -1254,6 +1257,7 @@ def delete_document( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1278,18 +1282,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -1331,15 +1335,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1355,6 +1355,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "attributes"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, type: type, @@ -1390,23 +1394,23 @@ def get_index( collection_id:, key: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -1435,28 +1439,29 @@ def delete_index( collection_id:, key: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1485,13 +1490,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/vectorsdb/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1528,13 +1533,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/vectorsdb/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1564,13 +1569,13 @@ def list_operations( def get_replicas( database_id: ) - api_path = '/vectorsdb/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1597,13 +1602,13 @@ def get_replicas( def get_status( database_id: ) - api_path = '/vectorsdb/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/waf.rb b/lib/appwrite/services/waf.rb index 949dd1ee..24a3b0f7 100644 --- a/lib/appwrite/services/waf.rb +++ b/lib/appwrite/services/waf.rb @@ -137,7 +137,7 @@ def update_bypass_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -284,7 +284,7 @@ def update_challenge_rule( difficulty: nil, ttl: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -415,7 +415,7 @@ def update_deny_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -578,7 +578,7 @@ def update_rate_limit_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -728,7 +728,7 @@ def update_redirect_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -771,7 +771,7 @@ def update_redirect_rule( def get_rule( rule_id: ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -833,7 +833,7 @@ def get_rule( def delete_rule( rule_id: ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end diff --git a/lib/appwrite/services/webhooks.rb b/lib/appwrite/services/webhooks.rb index 893cc08e..8f1a17cd 100644 --- a/lib/appwrite/services/webhooks.rb +++ b/lib/appwrite/services/webhooks.rb @@ -47,8 +47,8 @@ def list( # @param [Array] events Events list. Maximum of 100 events are allowed. # @param [] enabled Enable or disable a webhook. # @param [] tls Certificate verification, false for disabled or true for enabled. - # @param [String] auth_username Webhook HTTP user. Max length: 256 chars. - # @param [String] auth_password Webhook HTTP password. Max length: 256 chars. + # @param [String] auth_username Webhook HTTP user. Max length: 255 chars. + # @param [String] auth_password Webhook HTTP password. Max length: 2048 chars. # @param [String] secret Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. # # @return [Webhook] @@ -63,8 +63,6 @@ def create( auth_password: nil, secret: nil ) - api_path = '/webhooks' - if webhook_id.nil? raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end @@ -81,6 +79,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "events"') end + api_path = '/webhooks' + api_params = { webhookId: webhook_id, url: url, @@ -117,13 +117,13 @@ def create( def get( webhook_id: ) - api_path = '/webhooks/{webhookId}' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end + api_path = '/webhooks/{webhookId}' + .gsub('{webhookId}', webhook_id) + api_params = {} api_headers = { @@ -149,8 +149,8 @@ def get( # @param [Array] events Events list. Maximum of 100 events are allowed. # @param [] enabled Enable or disable a webhook. # @param [] tls Certificate verification, false for disabled or true for enabled. - # @param [String] auth_username Webhook HTTP user. Max length: 256 chars. - # @param [String] auth_password Webhook HTTP password. Max length: 256 chars. + # @param [String] auth_username Webhook HTTP user. Max length: 255 chars. + # @param [String] auth_password Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. # # @return [Webhook] def update( @@ -163,10 +163,7 @@ def update( auth_username: nil, auth_password: nil ) - api_path = '/webhooks/{webhookId}' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end @@ -182,6 +179,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "events"') end + api_path = '/webhooks/{webhookId}' + .gsub('{webhookId}', webhook_id) + api_params = { name: name, url: url, @@ -216,18 +216,19 @@ def update( def delete( webhook_id: ) - api_path = '/webhooks/{webhookId}' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end + api_path = '/webhooks/{webhookId}' + .gsub('{webhookId}', webhook_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -250,13 +251,13 @@ def update_secret( webhook_id:, secret: nil ) - api_path = '/webhooks/{webhookId}/secret' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end + api_path = '/webhooks/{webhookId}/secret' + .gsub('{webhookId}', webhook_id) + api_params = { secret: secret, } diff --git a/lib/appwrite/topic.rb b/lib/appwrite/topic.rb new file mode 100644 index 00000000..28935976 --- /dev/null +++ b/lib/appwrite/topic.rb @@ -0,0 +1,102 @@ +module Appwrite + # Helper to build MQTT topics for `Push`, level by level. + # + # Topic.path(['user', user_id, 'notification']) # "user/123/notification" + # Topic.path(['user']).any.path(['notification']) # "user/+/notification" + # Topic.path(['org']).any.path(['logs']).all # "org/+/logs/#" + # + # `any` matches exactly one level and `all` everything below, at any depth (including the + # parent itself). `all` ends the topic, so it returns a ResolvedTopic. + class Topic + private_class_method :new + + # Start a topic with the given levels, e.g. `Topic.path(['user', user_id])`. + def self.path(levels) + new([]).path(levels) + end + + # Start a topic with a single-level wildcard (`+`). + def self.any + new(['+']) + end + + # The multi-level wildcard alone (`#`): matches every topic. + def self.all + ResolvedTopic.new(['#']) + end + + def initialize(levels) + @levels = levels.freeze + end + + # Append the given levels. + def path(levels) + self.class.send(:new, @levels + self.class.send(:levels_of, levels)) + end + + # Append a single-level wildcard (`+`): matches exactly one level. + def any + self.class.send(:new, @levels + ['+']) + end + + # Append the multi-level wildcard (`#`) and end the topic. + def all + ResolvedTopic.new(@levels + ['#']) + end + + def to_s + @levels.join('/') + end + + # Validate the levels passed to `path`: a non-empty array of non-empty strings, none holding + # the level separator `/` or the wildcards `+` and `#` (use `any` and `all` for those). + def self.levels_of(levels) + raise ArgumentError, "path() expects an array, e.g. path(['user'])" unless levels.is_a?(Array) + raise ArgumentError, 'path() needs at least one level' if levels.empty? + + levels.each_with_index do |level, index| + unless level.is_a?(String) + type = level.nil? ? 'null' : level.class.name + raise ArgumentError, "level at index #{index} must be a string, got #{type}" + end + raise ArgumentError, "empty level at index #{index}" if level.empty? + + if level.include?('/') + parts = level.split('/', -1).map { |part| "'#{part}'" }.join(', ') + raise ArgumentError, "\"#{level}\" contains \"/\", split it: path([#{parts}])" + end + raise ArgumentError, '"+" is reserved, use any()' if level == '+' + raise ArgumentError, "\"#{level}\" contains \"+\", use any() for wildcards" if level.include?('+') + raise ArgumentError, '"#" is reserved, use all()' if level == '#' + raise ArgumentError, "\"#{level}\" contains \"#\", use all() for wildcards" if level.include?('#') + end + + levels.dup + end + private_class_method :levels_of + end + + # A topic ended by `all`: nothing can be appended after the `#` wildcard. + class ResolvedTopic + # Created by Topic.all. + def initialize(levels) + @levels = levels.freeze + end + + def path(_levels) + raise NoMethodError, 'nothing can come after all()' + end + + def any + raise NoMethodError, 'nothing can come after all()' + end + + def all + raise NoMethodError, 'nothing can come after all()' + end + + def to_s + @levels.join('/') + end + end +end From 33bc898e8dfc73239119e45c5e11bfa6bc190b3b Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 15 Oct 2026 11:10:25 +0100 Subject: [PATCH 3/4] feat: SDK update for the 2.5.x majors --- CHANGELOG.md | 20 + README.md | 14 +- appwrite.gemspec | 2 +- docs/examples/account/list-logs.md | 17 - docs/examples/account/update-prefs.md | 4 +- docs/examples/avatars/get-screenshot.md | 3 +- docs/examples/databases/create-document.md | 6 +- docs/examples/databases/create-documents.md | 11 +- docs/examples/databases/create-index.md | 2 +- docs/examples/databases/delete-documents.md | 2 +- docs/examples/databases/update-document.md | 6 +- docs/examples/databases/update-documents.md | 6 +- docs/examples/databases/upsert-document.md | 6 +- docs/examples/databases/upsert-documents.md | 11 +- docs/examples/documentsdb/create-document.md | 6 +- docs/examples/documentsdb/create-documents.md | 11 +- docs/examples/documentsdb/create-index.md | 2 +- docs/examples/documentsdb/delete-documents.md | 2 +- docs/examples/documentsdb/upsert-documents.md | 11 +- .../embeddings/create-text-embeddings.md | 2 +- docs/examples/functions/update.md | 3 +- docs/examples/graphql/mutation.md | 4 +- docs/examples/graphql/query.md | 4 +- .../messaging/create-twilio-provider.md | 2 +- docs/examples/mongo/create-restoration.md | 5 +- .../promote-restoration.md} | 9 +- docs/examples/mysql/create-restoration.md | 5 +- .../promote-restoration.md} | 8 +- docs/examples/oauth2/approve.md | 2 +- docs/examples/oauth2/authorize-post.md | 4 +- docs/examples/oauth2/authorize.md | 4 +- .../oauth2/create-device-authorization.md | 4 +- docs/examples/oauth2/create-grant.md | 2 +- docs/examples/oauth2/create-par.md | 4 +- docs/examples/oauth2/create-token.md | 4 +- docs/examples/oauth2/get-grant.md | 2 +- docs/examples/oauth2/list-organizations.md | 2 +- docs/examples/oauth2/list-projects.md | 2 +- docs/examples/oauth2/reject.md | 2 +- docs/examples/oauth2/revoke.md | 2 +- docs/examples/organization/create-key.md | 20 - docs/examples/organization/update-key.md | 20 - .../examples/postgresql/create-restoration.md | 5 +- .../promote-restoration.md} | 7 +- docs/examples/project/create-ephemeral-key.md | 2 +- docs/examples/project/create-smtp-test.md | 2 +- docs/examples/project/update-key.md | 2 +- docs/examples/project/update-labels.md | 2 +- .../examples/project/update-o-auth-2-kakao.md | 4 +- .../get-key.md => proxy/create-smtp-rule.md} | 8 +- docs/examples/storage/get-file-preview.md | 2 +- docs/examples/tablesdb/create-index.md | 2 +- docs/examples/tablesdb/create-row.md | 6 +- docs/examples/tablesdb/create-rows.md | 11 +- docs/examples/tablesdb/delete-rows.md | 2 +- docs/examples/tablesdb/update-row.md | 6 +- docs/examples/tablesdb/update-rows.md | 6 +- docs/examples/tablesdb/upsert-row.md | 6 +- docs/examples/tablesdb/upsert-rows.md | 11 +- docs/examples/teams/create-membership.md | 2 +- docs/examples/teams/update-membership.md | 2 +- docs/examples/users/update-labels.md | 2 +- docs/examples/vectorsdb/create-collection.md | 2 +- docs/examples/vectorsdb/create-document.md | 2 +- docs/examples/vectorsdb/create-documents.md | 15 +- docs/examples/vectorsdb/create-index.md | 2 +- docs/examples/vectorsdb/create-operations.md | 10 +- docs/examples/vectorsdb/delete-documents.md | 2 +- docs/examples/vectorsdb/update-collection.md | 2 +- docs/examples/vectorsdb/upsert-documents.md | 15 +- docs/examples/webhooks/create.md | 2 +- docs/examples/webhooks/update.md | 2 +- lib/appwrite.rb | 15 +- lib/appwrite/client.rb | 34 +- lib/appwrite/enums/billing_plan_group.rb | 1 - lib/appwrite/enums/execution_trigger.rb | 1 + lib/appwrite/enums/organization_key_scopes.rb | 22 - lib/appwrite/enums/proxy_rule_protocol.rb | 8 + lib/appwrite/models/activity_event.rb | 1 + lib/appwrite/models/activity_event_list.rb | 1 + lib/appwrite/models/additional_resource.rb | 1 + lib/appwrite/models/algo_argon2.rb | 1 + lib/appwrite/models/algo_bcrypt.rb | 1 + lib/appwrite/models/algo_md5.rb | 1 + lib/appwrite/models/algo_phpass.rb | 1 + lib/appwrite/models/algo_scrypt.rb | 1 + lib/appwrite/models/algo_scrypt_modified.rb | 1 + lib/appwrite/models/algo_sha.rb | 1 + lib/appwrite/models/app.rb | 1 + lib/appwrite/models/app_installation.rb | 1 + lib/appwrite/models/app_installation_list.rb | 1 + lib/appwrite/models/app_key.rb | 1 + lib/appwrite/models/app_key_list.rb | 1 + lib/appwrite/models/app_scope.rb | 1 + lib/appwrite/models/app_scope_list.rb | 1 + lib/appwrite/models/app_secret.rb | 1 + lib/appwrite/models/app_secret_list.rb | 1 + lib/appwrite/models/app_secret_plaintext.rb | 1 + lib/appwrite/models/apps_list.rb | 1 + lib/appwrite/models/attribute_bigint.rb | 1 + lib/appwrite/models/attribute_boolean.rb | 1 + lib/appwrite/models/attribute_datetime.rb | 1 + lib/appwrite/models/attribute_email.rb | 1 + lib/appwrite/models/attribute_enum.rb | 1 + lib/appwrite/models/attribute_float.rb | 1 + lib/appwrite/models/attribute_integer.rb | 1 + lib/appwrite/models/attribute_ip.rb | 1 + lib/appwrite/models/attribute_line.rb | 1 + lib/appwrite/models/attribute_list.rb | 1 + lib/appwrite/models/attribute_longtext.rb | 1 + lib/appwrite/models/attribute_mediumtext.rb | 1 + lib/appwrite/models/attribute_object.rb | 1 + lib/appwrite/models/attribute_point.rb | 1 + lib/appwrite/models/attribute_polygon.rb | 1 + lib/appwrite/models/attribute_relationship.rb | 1 + lib/appwrite/models/attribute_string.rb | 1 + lib/appwrite/models/attribute_text.rb | 1 + lib/appwrite/models/attribute_url.rb | 1 + lib/appwrite/models/attribute_varchar.rb | 1 + lib/appwrite/models/attribute_vector.rb | 1 + lib/appwrite/models/backup_archive.rb | 1 + lib/appwrite/models/backup_archive_list.rb | 1 + lib/appwrite/models/backup_policy.rb | 1 + lib/appwrite/models/backup_policy_list.rb | 1 + lib/appwrite/models/backup_restoration.rb | 1 + .../models/backup_restoration_list.rb | 1 + lib/appwrite/models/billing_limits.rb | 16 +- lib/appwrite/models/billing_plan.rb | 20 +- .../models/billing_plan_addon_details.rb | 1 + .../billing_plan_dedicated_database_limits.rb | 38 +- lib/appwrite/models/billing_plan_limits.rb | 4 +- .../models/billing_plan_supported_addons.rb | 1 + lib/appwrite/models/block.rb | 37 +- lib/appwrite/models/bucket.rb | 1 + lib/appwrite/models/bucket_list.rb | 1 + lib/appwrite/models/collection.rb | 1 + lib/appwrite/models/collection_list.rb | 1 + lib/appwrite/models/column_bigint.rb | 1 + lib/appwrite/models/column_boolean.rb | 1 + lib/appwrite/models/column_datetime.rb | 1 + lib/appwrite/models/column_email.rb | 1 + lib/appwrite/models/column_enum.rb | 1 + lib/appwrite/models/column_float.rb | 1 + lib/appwrite/models/column_index.rb | 3 +- lib/appwrite/models/column_index_list.rb | 1 + lib/appwrite/models/column_integer.rb | 1 + lib/appwrite/models/column_ip.rb | 1 + lib/appwrite/models/column_line.rb | 1 + lib/appwrite/models/column_list.rb | 1 + lib/appwrite/models/column_longtext.rb | 1 + lib/appwrite/models/column_mediumtext.rb | 1 + lib/appwrite/models/column_point.rb | 1 + lib/appwrite/models/column_polygon.rb | 1 + lib/appwrite/models/column_relationship.rb | 1 + lib/appwrite/models/column_string.rb | 1 + lib/appwrite/models/column_text.rb | 1 + lib/appwrite/models/column_url.rb | 1 + lib/appwrite/models/column_varchar.rb | 1 + lib/appwrite/models/continent.rb | 1 + lib/appwrite/models/continent_list.rb | 1 + lib/appwrite/models/country.rb | 1 + lib/appwrite/models/country_list.rb | 1 + lib/appwrite/models/currency.rb | 1 + lib/appwrite/models/currency_list.rb | 1 + lib/appwrite/models/database.rb | 1 + lib/appwrite/models/database_list.rb | 1 + lib/appwrite/models/database_migration.rb | 1 + .../models/database_migration_list.rb | 1 + lib/appwrite/models/database_status.rb | 5 +- .../models/database_status_connections.rb | 1 + .../models/database_status_replica.rb | 1 + lib/appwrite/models/database_status_volume.rb | 1 + lib/appwrite/models/dedicated_database.rb | 1 + .../models/dedicated_database_backup.rb | 1 + .../models/dedicated_database_backup_list.rb | 1 + .../dedicated_database_backup_storage.rb | 1 + .../models/dedicated_database_branch.rb | 1 + .../models/dedicated_database_branch_list.rb | 1 + .../models/dedicated_database_execution.rb | 1 + .../dedicated_database_execution_column.rb | 1 + .../models/dedicated_database_extensions.rb | 1 + .../models/dedicated_database_list.rb | 1 + .../models/dedicated_database_member.rb | 1 + .../models/dedicated_database_operation.rb | 1 + .../dedicated_database_operation_list.rb | 1 + .../models/dedicated_database_pitr_windows.rb | 1 + .../models/dedicated_database_pooler.rb | 1 + .../models/dedicated_database_replicas.rb | 1 + .../models/dedicated_database_restoration.rb | 6 + .../dedicated_database_restoration_list.rb | 1 + .../dedicated_database_specification.rb | 1 + .../dedicated_database_specification_list.rb | 12 +- ...edicated_database_specification_pricing.rb | 42 - lib/appwrite/models/deployment.rb | 1 + lib/appwrite/models/deployment_list.rb | 1 + lib/appwrite/models/dev_key.rb | 62 - lib/appwrite/models/document.rb | 1 + lib/appwrite/models/document_list.rb | 1 + lib/appwrite/models/email_template.rb | 1 + lib/appwrite/models/email_template_list.rb | 1 + lib/appwrite/models/embedding.rb | 1 + lib/appwrite/models/embedding_list.rb | 1 + lib/appwrite/models/ephemeral_key.rb | 1 + lib/appwrite/models/execution.rb | 2 + lib/appwrite/models/execution_list.rb | 1 + lib/appwrite/models/file.rb | 1 + lib/appwrite/models/file_list.rb | 1 + lib/appwrite/models/framework.rb | 1 + lib/appwrite/models/framework_adapter.rb | 1 + lib/appwrite/models/framework_list.rb | 1 + lib/appwrite/models/function.rb | 14 +- lib/appwrite/models/function_list.rb | 1 + lib/appwrite/models/headers.rb | 1 + lib/appwrite/models/identity.rb | 1 + lib/appwrite/models/identity_list.rb | 1 + lib/appwrite/models/index.rb | 3 +- lib/appwrite/models/index_list.rb | 1 + lib/appwrite/models/insight.rb | 1 + lib/appwrite/models/insight_cta.rb | 1 + lib/appwrite/models/insight_list.rb | 1 + lib/appwrite/models/jwt.rb | 1 + lib/appwrite/models/key.rb | 1 + lib/appwrite/models/key_list.rb | 1 + lib/appwrite/models/language.rb | 1 + lib/appwrite/models/language_list.rb | 1 + lib/appwrite/models/locale.rb | 1 + lib/appwrite/models/locale_code.rb | 1 + lib/appwrite/models/locale_code_list.rb | 1 + lib/appwrite/models/log.rb | 132 -- lib/appwrite/models/log_list.rb | 32 - lib/appwrite/models/membership.rb | 1 + lib/appwrite/models/membership_list.rb | 1 + lib/appwrite/models/message.rb | 1 + lib/appwrite/models/message_list.rb | 1 + lib/appwrite/models/mfa_challenge.rb | 1 + lib/appwrite/models/mfa_challenge_secret.rb | 1 + lib/appwrite/models/mfa_factors.rb | 1 + lib/appwrite/models/mfa_recovery_codes.rb | 1 + lib/appwrite/models/mfa_type.rb | 1 + lib/appwrite/models/mock_number.rb | 1 + lib/appwrite/models/mock_number_list.rb | 1 + lib/appwrite/models/o_auth2_amazon.rb | 1 + lib/appwrite/models/o_auth2_apple.rb | 1 + lib/appwrite/models/o_auth2_appwrite.rb | 1 + lib/appwrite/models/o_auth2_auth0.rb | 3 +- lib/appwrite/models/o_auth2_authentik.rb | 1 + lib/appwrite/models/o_auth2_autodesk.rb | 1 + lib/appwrite/models/o_auth2_bitbucket.rb | 1 + lib/appwrite/models/o_auth2_bitly.rb | 1 + lib/appwrite/models/o_auth2_box.rb | 1 + lib/appwrite/models/o_auth2_cloudflare.rb | 1 + lib/appwrite/models/o_auth2_dailymotion.rb | 1 + lib/appwrite/models/o_auth2_discord.rb | 3 +- lib/appwrite/models/o_auth2_disqus.rb | 1 + lib/appwrite/models/o_auth2_dropbox.rb | 1 + lib/appwrite/models/o_auth2_etsy.rb | 1 + lib/appwrite/models/o_auth2_facebook.rb | 1 + lib/appwrite/models/o_auth2_figma.rb | 1 + lib/appwrite/models/o_auth2_fusion_auth.rb | 1 + lib/appwrite/models/o_auth2_github.rb | 3 +- lib/appwrite/models/o_auth2_gitlab.rb | 1 + lib/appwrite/models/o_auth2_google.rb | 1 + lib/appwrite/models/o_auth2_hugging_face.rb | 1 + lib/appwrite/models/o_auth2_keycloak.rb | 1 + lib/appwrite/models/o_auth2_kick.rb | 1 + lib/appwrite/models/o_auth2_linkedin.rb | 1 + lib/appwrite/models/o_auth2_microsoft.rb | 3 +- lib/appwrite/models/o_auth2_notion.rb | 1 + lib/appwrite/models/o_auth2_oidc.rb | 11 +- lib/appwrite/models/o_auth2_okta.rb | 3 +- lib/appwrite/models/o_auth2_paypal.rb | 1 + lib/appwrite/models/o_auth2_podio.rb | 1 + lib/appwrite/models/o_auth2_provider_list.rb | 1 + lib/appwrite/models/o_auth2_resend.rb | 1 + lib/appwrite/models/o_auth2_salesforce.rb | 3 +- lib/appwrite/models/o_auth2_slack.rb | 1 + lib/appwrite/models/o_auth2_spotify.rb | 1 + lib/appwrite/models/o_auth2_stripe.rb | 1 + lib/appwrite/models/o_auth2_tradeshift.rb | 1 + lib/appwrite/models/o_auth2_twitch.rb | 1 + lib/appwrite/models/o_auth2_word_press.rb | 1 + lib/appwrite/models/o_auth2_x.rb | 1 + lib/appwrite/models/o_auth2_yahoo.rb | 1 + lib/appwrite/models/o_auth2_yandex.rb | 1 + lib/appwrite/models/o_auth2_zoho.rb | 3 +- lib/appwrite/models/o_auth2_zoom.rb | 1 + lib/appwrite/models/oauth2_approve.rb | 1 + lib/appwrite/models/oauth2_authorize.rb | 1 + lib/appwrite/models/oauth2_consent.rb | 1 + lib/appwrite/models/oauth2_consent_list.rb | 1 + lib/appwrite/models/oauth2_consent_token.rb | 1 + .../models/oauth2_consent_token_list.rb | 1 + .../models/oauth2_device_authorization.rb | 1 + lib/appwrite/models/oauth2_grant.rb | 1 + lib/appwrite/models/oauth2_organization.rb | 1 + .../models/oauth2_organization_list.rb | 1 + lib/appwrite/models/oauth2_par.rb | 1 + lib/appwrite/models/oauth2_project.rb | 1 + lib/appwrite/models/oauth2_project_list.rb | 1 + lib/appwrite/models/oauth2_reject.rb | 1 + lib/appwrite/models/oauth2_token.rb | 1 + lib/appwrite/models/organization.rb | 1 + lib/appwrite/models/passkey.rb | 1 + lib/appwrite/models/passkey_challenge.rb | 1 + lib/appwrite/models/passkey_list.rb | 1 + lib/appwrite/models/phone.rb | 1 + lib/appwrite/models/phone_list.rb | 1 + lib/appwrite/models/platform_android.rb | 1 + lib/appwrite/models/platform_apple.rb | 1 + lib/appwrite/models/platform_linux.rb | 1 + lib/appwrite/models/platform_list.rb | 1 + lib/appwrite/models/platform_web.rb | 1 + lib/appwrite/models/platform_windows.rb | 1 + .../models/policy_deny_aliased_email.rb | 1 + .../models/policy_deny_corporate_email.rb | 1 + .../models/policy_deny_disposable_email.rb | 1 + lib/appwrite/models/policy_deny_free_email.rb | 1 + lib/appwrite/models/policy_list.rb | 1 + .../models/policy_membership_privacy.rb | 1 + lib/appwrite/models/policy_mfa_factors.rb | 1 + lib/appwrite/models/policy_passkey.rb | 1 + .../models/policy_password_dictionary.rb | 1 + .../models/policy_password_history.rb | 1 + .../models/policy_password_personal_data.rb | 1 + .../models/policy_password_strength.rb | 1 + lib/appwrite/models/policy_session_alert.rb | 1 + .../models/policy_session_duration.rb | 1 + .../models/policy_session_invalidation.rb | 1 + lib/appwrite/models/policy_session_limit.rb | 1 + lib/appwrite/models/policy_user_limit.rb | 1 + lib/appwrite/models/postgres_extension.rb | 1 + lib/appwrite/models/presence.rb | 1 + lib/appwrite/models/presence_list.rb | 1 + lib/appwrite/models/program.rb | 1 + lib/appwrite/models/project.rb | 30 +- lib/appwrite/models/project_auth_method.rb | 1 + lib/appwrite/models/project_list.rb | 1 + lib/appwrite/models/project_protocol.rb | 1 + lib/appwrite/models/project_service.rb | 1 + lib/appwrite/models/provider.rb | 3 +- lib/appwrite/models/provider_list.rb | 1 + lib/appwrite/models/proxy_invalidation.rb | 1 + lib/appwrite/models/proxy_rule.rb | 25 +- lib/appwrite/models/proxy_rule_list.rb | 1 + lib/appwrite/models/report.rb | 1 + lib/appwrite/models/report_list.rb | 1 + lib/appwrite/models/resource_token.rb | 1 + lib/appwrite/models/resource_token_list.rb | 1 + lib/appwrite/models/row.rb | 1 + lib/appwrite/models/row_list.rb | 1 + lib/appwrite/models/runtime.rb | 1 + lib/appwrite/models/runtime_list.rb | 1 + lib/appwrite/models/session.rb | 1 + lib/appwrite/models/session_list.rb | 1 + lib/appwrite/models/site.rb | 1 + lib/appwrite/models/site_list.rb | 1 + lib/appwrite/models/specification.rb | 1 + lib/appwrite/models/specification_list.rb | 1 + lib/appwrite/models/subscriber.rb | 1 + lib/appwrite/models/subscriber_list.rb | 1 + lib/appwrite/models/table.rb | 1 + lib/appwrite/models/table_list.rb | 1 + lib/appwrite/models/target.rb | 1 + lib/appwrite/models/target_list.rb | 1 + lib/appwrite/models/team.rb | 1 + lib/appwrite/models/team_list.rb | 1 + lib/appwrite/models/token.rb | 1 + lib/appwrite/models/token_secret.rb | 1 + lib/appwrite/models/topic.rb | 1 + lib/appwrite/models/topic_list.rb | 1 + lib/appwrite/models/transaction.rb | 1 + lib/appwrite/models/transaction_list.rb | 1 + lib/appwrite/models/usage_billing_plan.rb | 32 +- lib/appwrite/models/user.rb | 1 + lib/appwrite/models/user_list.rb | 1 + lib/appwrite/models/variable.rb | 1 + lib/appwrite/models/variable_list.rb | 1 + lib/appwrite/models/vectorsdb_collection.rb | 1 + .../models/vectorsdb_collection_list.rb | 1 + lib/appwrite/models/webhook.rb | 1 + lib/appwrite/models/webhook_list.rb | 1 + lib/appwrite/query.rb | 190 +++ lib/appwrite/query/builder.rb | 361 +++++ lib/appwrite/services/account.rb | 244 ++-- lib/appwrite/services/activities.rb | 8 +- lib/appwrite/services/advisor.rb | 37 +- lib/appwrite/services/apps.rb | 178 +-- lib/appwrite/services/avatars.rb | 42 +- lib/appwrite/services/backups.rb | 60 +- lib/appwrite/services/databases.rb | 946 ++++++------- lib/appwrite/services/documents_db.rb | 385 +++--- lib/appwrite/services/domains.rb | 110 +- lib/appwrite/services/embeddings.rb | 4 +- lib/appwrite/services/functions.rb | 226 ++-- lib/appwrite/services/graphql.rb | 8 +- lib/appwrite/services/messaging.rb | 308 ++--- lib/appwrite/services/mongo.rb | 324 +++-- lib/appwrite/services/mysql.rb | 356 +++-- lib/appwrite/services/oauth2.rb | 54 +- lib/appwrite/services/organization.rb | 301 +---- lib/appwrite/services/postgresql.rb | 384 +++--- lib/appwrite/services/presences.rb | 33 +- lib/appwrite/services/project.rb | 291 ++-- lib/appwrite/services/proxy.rb | 93 +- lib/appwrite/services/sites.rb | 212 +-- lib/appwrite/services/storage.rb | 121 +- lib/appwrite/services/tables_db.rb | 1170 +++++++++-------- lib/appwrite/services/teams.rb | 164 +-- lib/appwrite/services/tokens.rb | 49 +- lib/appwrite/services/users.rb | 369 +++--- lib/appwrite/services/vectors_db.rb | 357 ++--- lib/appwrite/services/waf.rb | 14 +- lib/appwrite/services/webhooks.rb | 45 +- lib/appwrite/topic.rb | 53 + 414 files changed, 4813 insertions(+), 3992 deletions(-) delete mode 100644 docs/examples/account/list-logs.md rename docs/examples/{users/list-logs.md => mongo/promote-restoration.md} (65%) rename docs/examples/{organization/list-keys.md => mysql/promote-restoration.md} (65%) delete mode 100644 docs/examples/organization/create-key.md delete mode 100644 docs/examples/organization/update-key.md rename docs/examples/{organization/delete-key.md => postgresql/promote-restoration.md} (63%) rename docs/examples/{organization/get-key.md => proxy/create-smtp-rule.md} (62%) delete mode 100644 lib/appwrite/enums/organization_key_scopes.rb create mode 100644 lib/appwrite/enums/proxy_rule_protocol.rb delete mode 100644 lib/appwrite/models/dedicated_database_specification_pricing.rb delete mode 100644 lib/appwrite/models/dev_key.rb delete mode 100644 lib/appwrite/models/log.rb delete mode 100644 lib/appwrite/models/log_list.rb create mode 100644 lib/appwrite/query/builder.rb create mode 100644 lib/appwrite/topic.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index cdc8ff1a..6bc66b03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Change Log +## 29.0.0 + +* Breaking: requests send `X-Appwrite-Response-Format: 2.5.0`; responses follow the 2.5 shapes +* Breaking: removed `account.list_logs`, `users.list_logs` and the `Log`/`LogList` models +* Breaking: removed `organization.create_key`, `get_key`, `list_keys`, `update_key` and `delete_key`, and `OrganizationKeyScopes`; use `organization.list_project_keys`, `get_project_key`, `update_project_key` and `delete_project_key` instead +* Breaking: removed `Client#set_dev_key`, the `DevKey` model and `Project#dev_keys` +* Breaking: removed `BillingPlanGroup::STARTER`; use `BillingPlanGroup::FREE` +* Breaking: `list_specifications` returns each specification's prices and overage rates on the row itself. Removed the list-level `pricing` field and the `DedicatedDatabaseSpecificationPricing` model +* Breaking: removed `Block` fields `reason`, `project_name`, `region`, `organization_name`, `organization_id` and `billing_plan` +* Breaking: OAuth2 `resource:` params now take an array +* Breaking: `BackupRestoration#options` is now a hash +* Breaking: some response fields became optional, such as `BillingPlan#usage` and `DedicatedDatabase#engine` +* Added: `Topic` helper to build MQTT topics for push messages +* Added: `mongo`, `mysql` and `postgresql` `promote_restoration`, `restore_mode:`, `target_name:` and `auto_promote:` on `create_restoration`, and `DedicatedDatabaseRestoration#restore_mode` +* Added: `proxy.create_smtp_rule`, the `ProxyRuleProtocol` enum and `ProxyRule#protocol` +* Added: `email_enabled:` on `functions.update` and `Function`, and `ExecutionTrigger::EMAIL` +* Added: `Query` aggregates (`count`, `count_distinct`, `sum`, `avg`, `min`, `max` and more), `group_by`, `having`, `distinct`, joins, `relationship`, `covers`, `spatial_equals` and `page` +* Added: `Query.builder` to chain queries; `build()` returns the query list +* Updated: missing response fields fall back to their documented defaults in more models + ## 28.4.0 * Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones diff --git a/README.md b/README.md index ebd62348..f37667f0 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Ruby SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.0.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 1.9.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-ruby/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-ruby/releases) when APIs differ. Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Ruby SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -35,7 +35,7 @@ client .set_endpoint(ENV["APPWRITE_ENDPOINT"]) # Your API Endpoint .set_project(ENV["APPWRITE_PROJECT"]) # Your project ID .set_key(ENV["APPWRITE_SECRET"]) # Your secret API key - .setSelfSigned() # Use only on dev mode with a self-signed SSL cert + .set_self_signed # Use only on dev mode with a self-signed SSL cert ; ``` @@ -45,7 +45,7 @@ Once your SDK object is set, create any of the Appwrite service objects and choo ```ruby users = Appwrite::Users.new(client); -user = users.create(userId: Appwrite::ID::unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); +user = users.create(user_id: Appwrite::ID::unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); ``` ### Full Example @@ -58,12 +58,12 @@ client .set_endpoint(ENV["APPWRITE_ENDPOINT"]) # Your API Endpoint .set_project(ENV["APPWRITE_PROJECT"]) # Your project ID .set_key(ENV["APPWRITE_SECRET"]) # Your secret API key - .setSelfSigned() # Use only on dev mode with a self-signed SSL cert + .set_self_signed # Use only on dev mode with a self-signed SSL cert ; users = Appwrite::Users.new(client); -user = users.create(userId: Appwrite::ID::unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); +user = users.create(user_id: Appwrite::ID::unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); ``` ### Error Handling @@ -73,7 +73,7 @@ The Appwrite Ruby SDK raises `Appwrite::Exception` object with `message`, `code` users = Appwrite::Users.new(client); begin - user = users.create(userId: Appwrite::ID::unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); + user = users.create(user_id: Appwrite::ID::unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); rescue Appwrite::Exception => error puts error.message end diff --git a/appwrite.gemspec b/appwrite.gemspec index 7fe70b3b..4054abff 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '28.4.0' + spec.version = '29.0.0' spec.license = 'BSD-3-Clause' spec.summary = 'Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API' spec.author = 'Appwrite Team' diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md deleted file mode 100644 index 171d4306..00000000 --- a/docs/examples/account/list-logs.md +++ /dev/null @@ -1,17 +0,0 @@ -```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_logs( - queries: [], # optional - total: false # optional -) -``` diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index 847cff42..a4298139 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -12,8 +12,8 @@ account = Account.new(client) result = account.update_prefs( prefs: { - "language" => "en", - "timezone" => "UTC", + "language" => 'en', + "timezone" => 'UTC', "darkTheme" => true } ) diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 742c87fd..83a39ba7 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -14,8 +14,7 @@ avatars = Avatars.new(client) result = avatars.get_screenshot( url: 'https://example.com', headers: { - "Authorization" => "Bearer token123", - "X-Custom-Header" => "value" + "Accept-Language" => 'en-US,en;q=0.9' }, # optional viewport_width: 1920, # optional viewport_height: 1080, # optional diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 6398a210..09283549 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -17,9 +17,9 @@ result = databases.create_document( collection_id: '', document_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 30, "isAdmin" => false }, diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 60acd19f..25b4cbd9 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -13,7 +13,16 @@ databases = Databases.new(client) result = databases.create_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index e3e9238a..924f512f 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -16,7 +16,7 @@ result = databases.create_index( collection_id: '', key: '', type: DatabasesIndexType::KEY, - attributes: [], + attributes: ["username"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index c9309bd9..29ea3583 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -13,7 +13,7 @@ databases = Databases.new(client) result = databases.delete_documents( database_id: '', collection_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 27747e3b..af0d88d9 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -17,9 +17,9 @@ result = databases.update_document( collection_id: '', document_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 33, "isAdmin" => false }, # optional diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index 5ebb951f..e58b6480 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -14,9 +14,9 @@ result = databases.update_documents( database_id: '', collection_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 33, "isAdmin" => false }, # optional diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index d196769e..84b15775 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -17,9 +17,9 @@ result = databases.upsert_document( collection_id: '', document_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 30, "isAdmin" => false }, # optional diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 49432e01..6cf394c5 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -13,7 +13,16 @@ databases = Databases.new(client) result = databases.upsert_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/documentsdb/create-document.md b/docs/examples/documentsdb/create-document.md index 94b68b35..7c78f103 100644 --- a/docs/examples/documentsdb/create-document.md +++ b/docs/examples/documentsdb/create-document.md @@ -17,9 +17,9 @@ result = documents_db.create_document( collection_id: '', document_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 30, "isAdmin" => false }, diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index 1277f4ac..b895f1c5 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -13,7 +13,16 @@ documents_db = DocumentsDB.new(client) result = documents_db.create_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md index d1891f9a..a8c4e35f 100644 --- a/docs/examples/documentsdb/create-index.md +++ b/docs/examples/documentsdb/create-index.md @@ -16,7 +16,7 @@ result = documents_db.create_index( collection_id: '', key: '', type: DocumentsDBIndexType::KEY, - attributes: [], + attributes: ["username"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md index cd628c75..b1ea2032 100644 --- a/docs/examples/documentsdb/delete-documents.md +++ b/docs/examples/documentsdb/delete-documents.md @@ -13,7 +13,7 @@ documents_db = DocumentsDB.new(client) result = documents_db.delete_documents( database_id: '', collection_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md index f7f05970..0876756c 100644 --- a/docs/examples/documentsdb/upsert-documents.md +++ b/docs/examples/documentsdb/upsert-documents.md @@ -13,7 +13,16 @@ documents_db = DocumentsDB.new(client) result = documents_db.upsert_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index facbe573..fecbe281 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -12,7 +12,7 @@ client = Client.new embeddings = Embeddings.new(client) result = embeddings.create_text_embeddings( - texts: [], + texts: ["Appwrite helps developers build applications.", "Find documents with semantic search."], model: EmbeddingModel::NOMIC_EMBED_TEXT # optional ) ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index ff418bd5..1932fba5 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -34,6 +34,7 @@ result = functions.update( build_specification: 's-1vcpu-512mb', # optional runtime_specification: 's-1vcpu-512mb', # optional deployment_retention: 0, # optional - interval: 0 # optional + interval: 0, # optional + email_enabled: false # optional ) ``` diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index a71a8bd6..79ac983d 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -11,6 +11,8 @@ client = Client.new graphql = Graphql.new(client) result = graphql.mutation( - query: {} + query: { + "query" => 'mutation { accountUpdateName(name: "Walter") { name } }' + } ) ``` diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 49561b15..35046ab9 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -11,6 +11,8 @@ client = Client.new graphql = Graphql.new(client) result = graphql.query( - query: {} + query: { + "query" => 'query { localeGet { ip } }' + } ) ``` diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index fa86a835..a68eec6f 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -13,7 +13,7 @@ messaging = Messaging.new(client) result = messaging.create_twilio_provider( provider_id: '', name: '', - from: '+12065550100', # optional + from: '', # optional account_sid: '', # optional auth_token: '', # optional enabled: false # optional diff --git a/docs/examples/mongo/create-restoration.md b/docs/examples/mongo/create-restoration.md index 43f91beb..90210ea8 100644 --- a/docs/examples/mongo/create-restoration.md +++ b/docs/examples/mongo/create-restoration.md @@ -15,6 +15,9 @@ result = mongo.create_restoration( type: 'backup', # optional backup_id: '', # optional target_database_id: '', # optional - target_time: '2020-10-15T06:38:00.000+00:00' # optional + target_time: '2020-10-15T06:38:00.000+00:00', # optional + restore_mode: 'in_place', # optional + target_name: '', # optional + auto_promote: false # optional ) ``` diff --git a/docs/examples/users/list-logs.md b/docs/examples/mongo/promote-restoration.md similarity index 65% rename from docs/examples/users/list-logs.md rename to docs/examples/mongo/promote-restoration.md index dd9809e3..41bbe464 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/mongo/promote-restoration.md @@ -8,11 +8,10 @@ client = Client.new .set_project('') # Your project ID .set_key('') # Your secret API key -users = Users.new(client) +mongo = Mongo.new(client) -result = users.list_logs( - user_id: '', - queries: [], # optional - total: false # optional +result = mongo.promote_restoration( + database_id: '', + restoration_id: '' ) ``` diff --git a/docs/examples/mysql/create-restoration.md b/docs/examples/mysql/create-restoration.md index ad5aa058..25dc141e 100644 --- a/docs/examples/mysql/create-restoration.md +++ b/docs/examples/mysql/create-restoration.md @@ -15,6 +15,9 @@ result = mysql.create_restoration( type: 'backup', # optional backup_id: '', # optional target_database_id: '', # optional - target_time: '2020-10-15T06:38:00.000+00:00' # optional + target_time: '2020-10-15T06:38:00.000+00:00', # optional + restore_mode: 'in_place', # optional + target_name: '', # optional + auto_promote: false # optional ) ``` diff --git a/docs/examples/organization/list-keys.md b/docs/examples/mysql/promote-restoration.md similarity index 65% rename from docs/examples/organization/list-keys.md rename to docs/examples/mysql/promote-restoration.md index d54a2642..7f499e33 100644 --- a/docs/examples/organization/list-keys.md +++ b/docs/examples/mysql/promote-restoration.md @@ -8,10 +8,10 @@ client = Client.new .set_project('') # Your project ID .set_key('') # Your secret API key -organization = Organization.new(client) +mysql = Mysql.new(client) -result = organization.list_keys( - queries: [], # optional - total: false # optional +result = mysql.promote_restoration( + database_id: '', + restoration_id: '' ) ``` diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md index 6576dbec..99818b87 100644 --- a/docs/examples/oauth2/approve.md +++ b/docs/examples/oauth2/approve.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 75f092a2..d4f058ce 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -22,7 +22,7 @@ result = oauth2.authorize_post( prompt: '', # optional max_age: 0, # optional authorization_details: '', # optional - resource: '', # optional + resource: [], # optional audience: '', # optional request_uri: '' # optional ) diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index d7d5befc..474e4e96 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -22,7 +22,7 @@ result = oauth2.authorize( prompt: '', # optional max_age: 0, # optional authorization_details: '', # optional - resource: '', # 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 index 102671db..3fde848d 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -14,7 +14,7 @@ result = oauth2.create_device_authorization( client_id: '', # optional scope: '', # optional authorization_details: '', # optional - resource: '', # optional + resource: [], # optional audience: '' # optional ) ``` diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md index 9184cbf7..f4bff9f2 100644 --- a/docs/examples/oauth2/create-grant.md +++ b/docs/examples/oauth2/create-grant.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index 192e5ff1..2ac703ea 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -22,7 +22,7 @@ result = oauth2.create_par( prompt: '', # optional max_age: 0, # optional authorization_details: '', # optional - resource: '', # optional + resource: [], # optional audience: '' # optional ) ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index 6e0cabc1..8b0a9c52 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -19,7 +19,7 @@ result = oauth2.create_token( client_secret: '', # optional code_verifier: '', # optional redirect_uri: 'https://example.com', # optional - resource: '', # optional + resource: [], # optional audience: '' # optional ) ``` diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md index e6b80763..81985286 100644 --- a/docs/examples/oauth2/get-grant.md +++ b/docs/examples/oauth2/get-grant.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md index 28b026e4..2e9ed664 100644 --- a/docs/examples/oauth2/list-organizations.md +++ b/docs/examples/oauth2/list-organizations.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md index 3f8c64f2..f7a69362 100644 --- a/docs/examples/oauth2/list-projects.md +++ b/docs/examples/oauth2/list-projects.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md index bf00d990..e10fd752 100644 --- a/docs/examples/oauth2/reject.md +++ b/docs/examples/oauth2/reject.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md index 6b709451..36c5c145 100644 --- a/docs/examples/oauth2/revoke.md +++ b/docs/examples/oauth2/revoke.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/organization/create-key.md b/docs/examples/organization/create-key.md deleted file mode 100644 index 3d920ccc..00000000 --- a/docs/examples/organization/create-key.md +++ /dev/null @@ -1,20 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite -include Appwrite::Enums - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -organization = Organization.new(client) - -result = organization.create_key( - key_id: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTS_READ], - expire: '2020-10-15T06:38:00.000+00:00' # optional -) -``` diff --git a/docs/examples/organization/update-key.md b/docs/examples/organization/update-key.md deleted file mode 100644 index c7542126..00000000 --- a/docs/examples/organization/update-key.md +++ /dev/null @@ -1,20 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite -include Appwrite::Enums - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -organization = Organization.new(client) - -result = organization.update_key( - key_id: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTS_READ], - expire: '2020-10-15T06:38:00.000+00:00' # optional -) -``` diff --git a/docs/examples/postgresql/create-restoration.md b/docs/examples/postgresql/create-restoration.md index b4a8e988..12cd76c0 100644 --- a/docs/examples/postgresql/create-restoration.md +++ b/docs/examples/postgresql/create-restoration.md @@ -15,6 +15,9 @@ result = postgresql.create_restoration( type: 'backup', # optional backup_id: '', # optional target_database_id: '', # optional - target_time: '2020-10-15T06:38:00.000+00:00' # optional + target_time: '2020-10-15T06:38:00.000+00:00', # optional + restore_mode: 'in_place', # optional + target_name: '', # optional + auto_promote: false # optional ) ``` diff --git a/docs/examples/organization/delete-key.md b/docs/examples/postgresql/promote-restoration.md similarity index 63% rename from docs/examples/organization/delete-key.md rename to docs/examples/postgresql/promote-restoration.md index 0e490c3b..d0aa2bb3 100644 --- a/docs/examples/organization/delete-key.md +++ b/docs/examples/postgresql/promote-restoration.md @@ -8,9 +8,10 @@ client = Client.new .set_project('') # Your project ID .set_key('') # Your secret API key -organization = Organization.new(client) +postgresql = Postgresql.new(client) -result = organization.delete_key( - key_id: '' +result = postgresql.promote_restoration( + database_id: '', + restoration_id: '' ) ``` diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index 6f0d9b66..d7928fa5 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -12,7 +12,7 @@ client = Client.new project = Project.new(client) result = project.create_ephemeral_key( - scopes: [ProjectKeyScopes::PROJECT_READ], + scopes: [ProjectKeyScopes::USERS_READ], duration: 600 ) ``` diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index 1e1d1eae..34853638 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -11,6 +11,6 @@ client = Client.new project = Project.new(client) result = project.create_smtp_test( - emails: [] + emails: ["recipient@example.com"] ) ``` diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index b192315d..992775bb 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -14,7 +14,7 @@ project = Project.new(client) result = project.update_key( key_id: '', name: '', - scopes: [ProjectKeyScopes::PROJECT_READ], + scopes: [ProjectKeyScopes::USERS_READ], expire: '2020-10-15T06:38:00.000+00:00' # optional ) ``` diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index f57cec70..a01667b9 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -11,6 +11,6 @@ client = Client.new project = Project.new(client) result = project.update_labels( - labels: [] + labels: ["production"] ) ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index 035810f7..5acde9f9 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -14,7 +14,7 @@ project = Project.new(client) result = project.update_o_auth2_kakao( client_id: '', # optional client_secret: '', # optional - prompt: [ProjectOAuth2KakaoPrompt::NONE], # optional - enabled: false # optional + enabled: false, # optional + prompt: [ProjectOAuth2KakaoPrompt::NONE] # optional ) ``` diff --git a/docs/examples/organization/get-key.md b/docs/examples/proxy/create-smtp-rule.md similarity index 62% rename from docs/examples/organization/get-key.md rename to docs/examples/proxy/create-smtp-rule.md index 28899bb6..dbbc1c7d 100644 --- a/docs/examples/organization/get-key.md +++ b/docs/examples/proxy/create-smtp-rule.md @@ -8,9 +8,11 @@ client = Client.new .set_project('') # Your project ID .set_key('') # Your secret API key -organization = Organization.new(client) +proxy = Proxy.new(client) -result = organization.get_key( - key_id: '' +result = proxy.create_smtp_rule( + domain: 'example.com', + function_id: '', + branch: '' # optional ) ``` diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index 3b4ce03d..d40c3a5e 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -16,7 +16,7 @@ result = storage.get_file_preview( file_id: '', width: 0, # optional height: 0, # optional - gravity: ImageGravity::CENTER, # optional + gravity: ImageGravity::AUTO, # optional quality: -1, # optional border_width: 0, # optional border_color: 'FFFFFF', # optional diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index a0453818..d1e2dba7 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -16,7 +16,7 @@ result = tables_db.create_index( table_id: '', key: '', type: TablesDBIndexType::KEY, - columns: [], + columns: ["username"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 60aa4e9d..43a1c537 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -17,9 +17,9 @@ result = tables_db.create_row( table_id: '', row_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 30, "isAdmin" => false }, diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index 2fc8a2b1..9ff8dd78 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -13,7 +13,16 @@ tables_db = TablesDB.new(client) result = tables_db.create_rows( database_id: '', table_id: '', - rows: [], + rows: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 69ab29e8..41d6acdb 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -13,7 +13,7 @@ tables_db = TablesDB.new(client) result = tables_db.delete_rows( database_id: '', table_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index e801cb24..59f396a9 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -17,9 +17,9 @@ result = tables_db.update_row( table_id: '', row_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 33, "isAdmin" => false }, # optional diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 0eb800bd..ebe11daf 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -14,9 +14,9 @@ result = tables_db.update_rows( database_id: '', table_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 33, "isAdmin" => false }, # optional diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 7802e672..fe00e454 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -17,9 +17,9 @@ result = tables_db.upsert_row( table_id: '', row_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 33, "isAdmin" => false }, # optional diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index d450971f..9d5cce80 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -13,7 +13,16 @@ tables_db = TablesDB.new(client) result = tables_db.upsert_rows( database_id: '', table_id: '', - rows: [], + rows: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index c90a80d6..9016bb71 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -12,7 +12,7 @@ teams = Teams.new(client) result = teams.create_membership( team_id: '', - roles: [], + roles: ["editor"], email: 'email@example.com', # optional user_id: '', # optional phone: '+12065550100', # optional diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index f94e3879..898f7eae 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -13,6 +13,6 @@ teams = Teams.new(client) result = teams.update_membership( team_id: '', membership_id: '', - roles: [] + roles: ["editor"] ) ``` diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 0110cb9e..bdad6d04 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -12,6 +12,6 @@ users = Users.new(client) result = users.update_labels( user_id: '', - labels: [] + labels: ["subscriber"] ) ``` diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md index b449f541..4b16940b 100644 --- a/docs/examples/vectorsdb/create-collection.md +++ b/docs/examples/vectorsdb/create-collection.md @@ -16,7 +16,7 @@ result = vectors_db.create_collection( database_id: '', collection_id: '', name: '', - dimension: 1, + dimension: 4, permissions: [Permission.read(Role.any())], # optional document_security: false, # optional enabled: false # optional diff --git a/docs/examples/vectorsdb/create-document.md b/docs/examples/vectorsdb/create-document.md index 648d9b2c..a83f352c 100644 --- a/docs/examples/vectorsdb/create-document.md +++ b/docs/examples/vectorsdb/create-document.md @@ -24,7 +24,7 @@ result = vectors_db.create_document( "3" => 1.02 }, "metadata" => { - "key" => "value" + "key" => 'value' } }, permissions: [Permission.read(Role.any())], # optional diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index 9f3a4d4d..3a89c1ee 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -13,7 +13,20 @@ vectors_db = VectorsDB.new(client) result = vectors_db.create_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md index d7880ab2..60d2624a 100644 --- a/docs/examples/vectorsdb/create-index.md +++ b/docs/examples/vectorsdb/create-index.md @@ -16,7 +16,7 @@ result = vectors_db.create_index( collection_id: '', key: '', type: VectorsDBIndexType::HNSW_EUCLIDEAN, - attributes: [], + attributes: ["embeddings"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md index 6817930b..23e14d1c 100644 --- a/docs/examples/vectorsdb/create-operations.md +++ b/docs/examples/vectorsdb/create-operations.md @@ -19,7 +19,15 @@ result = vectors_db.create_operations( "collectionId": "", "documentId": "", "data": { - "name": "Walter O'Brien" + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } } } ] # optional diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md index bb1173a3..a050c8c3 100644 --- a/docs/examples/vectorsdb/delete-documents.md +++ b/docs/examples/vectorsdb/delete-documents.md @@ -13,7 +13,7 @@ vectors_db = VectorsDB.new(client) result = vectors_db.delete_documents( database_id: '', collection_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md index 0dfdac13..eee8c975 100644 --- a/docs/examples/vectorsdb/update-collection.md +++ b/docs/examples/vectorsdb/update-collection.md @@ -16,7 +16,7 @@ result = vectors_db.update_collection( database_id: '', collection_id: '', name: '', - dimension: 1, # optional + dimension: 4, # optional permissions: [Permission.read(Role.any())], # optional document_security: false, # optional enabled: false # optional diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md index d737f107..e1fea6cc 100644 --- a/docs/examples/vectorsdb/upsert-documents.md +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -13,7 +13,20 @@ vectors_db = VectorsDB.new(client) result = vectors_db.upsert_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index 9f231f7b..6d754424 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -14,7 +14,7 @@ result = webhooks.create( webhook_id: '', url: 'https://example.com/webhook', name: '', - events: [], + events: ["users.*.create"], enabled: false, # optional tls: false, # optional auth_username: '', # optional diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index ad3fa894..859d15f2 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -14,7 +14,7 @@ result = webhooks.update( webhook_id: '', name: '', url: 'https://example.com/webhook', - events: [], + events: ["users.*.create"], enabled: false, # optional tls: false, # optional auth_username: '', # optional diff --git a/lib/appwrite.rb b/lib/appwrite.rb index 7cf6053d..fbd8c530 100644 --- a/lib/appwrite.rb +++ b/lib/appwrite.rb @@ -11,6 +11,7 @@ require_relative 'appwrite/permission' require_relative 'appwrite/role' require_relative 'appwrite/id' +require_relative 'appwrite/topic' require_relative 'appwrite/operator' require_relative 'appwrite/models/row_list' @@ -24,7 +25,6 @@ require_relative 'appwrite/models/user_list' require_relative 'appwrite/models/session_list' require_relative 'appwrite/models/identity_list' -require_relative 'appwrite/models/log_list' require_relative 'appwrite/models/file_list' require_relative 'appwrite/models/bucket_list' require_relative 'appwrite/models/resource_token_list' @@ -111,7 +111,6 @@ require_relative 'appwrite/models/row' require_relative 'appwrite/models/document' require_relative 'appwrite/models/presence' -require_relative 'appwrite/models/log' require_relative 'appwrite/models/user' require_relative 'appwrite/models/algo_md5' require_relative 'appwrite/models/algo_sha' @@ -147,7 +146,6 @@ require_relative 'appwrite/models/webhook' require_relative 'appwrite/models/key' require_relative 'appwrite/models/ephemeral_key' -require_relative 'appwrite/models/dev_key' require_relative 'appwrite/models/mock_number' require_relative 'appwrite/models/o_auth2_github' require_relative 'appwrite/models/o_auth2_discord' @@ -211,6 +209,10 @@ require_relative 'appwrite/models/policy_membership_privacy' require_relative 'appwrite/models/policy_mfa_factors' require_relative 'appwrite/models/policy_passkey' +require_relative 'appwrite/models/policy_deny_aliased_email' +require_relative 'appwrite/models/policy_deny_disposable_email' +require_relative 'appwrite/models/policy_deny_free_email' +require_relative 'appwrite/models/policy_deny_corporate_email' require_relative 'appwrite/models/platform_web' require_relative 'appwrite/models/platform_apple' require_relative 'appwrite/models/platform_android' @@ -280,10 +282,6 @@ require_relative 'appwrite/models/organization' require_relative 'appwrite/models/dedicated_database_pitr_windows' require_relative 'appwrite/models/backup_policy' -require_relative 'appwrite/models/policy_deny_aliased_email' -require_relative 'appwrite/models/policy_deny_disposable_email' -require_relative 'appwrite/models/policy_deny_free_email' -require_relative 'appwrite/models/policy_deny_corporate_email' require_relative 'appwrite/models/dedicated_database_pooler' require_relative 'appwrite/models/postgres_extension' require_relative 'appwrite/models/program' @@ -291,7 +289,6 @@ require_relative 'appwrite/models/dedicated_database_restoration_list' 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' @@ -366,7 +363,6 @@ require_relative 'appwrite/enums/execution_method' require_relative 'appwrite/enums/message_priority' require_relative 'appwrite/enums/smtp_encryption' -require_relative 'appwrite/enums/organization_key_scopes' require_relative 'appwrite/enums/region' require_relative 'appwrite/enums/project_auth_method_id' require_relative 'appwrite/enums/project_o_auth2_auth0_prompt' @@ -420,6 +416,7 @@ require_relative 'appwrite/enums/platform_type' require_relative 'appwrite/enums/proxy_rule_deployment_resource_type' require_relative 'appwrite/enums/proxy_rule_status' +require_relative 'appwrite/enums/proxy_rule_protocol' require_relative 'appwrite/enums/message_status' require_relative 'appwrite/enums/billing_plan_group' require_relative 'appwrite/enums/domain_transfer_status_enum' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index 99f8f563..dab212e9 100644 --- a/lib/appwrite/client.rb +++ b/lib/appwrite/client.rb @@ -14,8 +14,8 @@ def initialize 'x-sdk-name' => 'Ruby', 'x-sdk-platform' => 'server', 'x-sdk-language' => 'ruby', - 'x-sdk-version' => '28.4.0', - 'X-Appwrite-Response-Format' => '2.0.0' + 'x-sdk-version' => '29.0.0', + 'X-Appwrite-Response-Format' => '2.5.0' } @endpoint = 'https://cloud.appwrite.io/v1' @config = {} @@ -130,20 +130,6 @@ def set_forwarded_user_agent(value) self end - # Set DevKey - # - # Your secret dev API key - # - # @param [String] value The value to set for the DevKey header - # - # @return [self] - def set_dev_key(value) - add_header('x-appwrite-dev-key', value) - @config['devkey'] = value - - self - end - # Set Cookie # # The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @@ -265,6 +251,8 @@ def call( params: {}, response_type: nil ) + params = params.transform_values { |value| Query._flatten(value) } + separator = path.include?('?') ? '&' : '?' uri = URI.parse(@endpoint + path + ((method == "GET" && params.length) ? separator + encode(params) : '')) @@ -283,6 +271,16 @@ def chunked_upload( ) input_file = params[param_name.to_sym] + if input_file.nil? + return call( + method: method, + path: path, + headers: headers, + params: params, + response_type: response_type, + ) + end + case input_file.source_type when 'path' size = ::File.size(input_file.path) @@ -290,7 +288,7 @@ def chunked_upload( size = input_file.data.bytesize end - if size < @chunk_size + if size <= @chunk_size || response_type == "text" if input_file.source_type == 'path' input_file.data = IO.read(input_file.path) end @@ -546,6 +544,8 @@ def decode_text(response) def encode_form_data(value, key = nil) case value when Hash + return encode_form_data(value.to_json, key) unless key.nil? + value.map { |k, v| encode_form_data(v, k) }.join when Array value.map { |v| encode_form_data(v, "#{key}[]") }.join diff --git a/lib/appwrite/enums/billing_plan_group.rb b/lib/appwrite/enums/billing_plan_group.rb index 1f3ca3cf..59fde6e6 100644 --- a/lib/appwrite/enums/billing_plan_group.rb +++ b/lib/appwrite/enums/billing_plan_group.rb @@ -1,7 +1,6 @@ module Appwrite module Enums module BillingPlanGroup - STARTER = 'starter' FREE = 'free' START = 'start' PRO = 'pro' diff --git a/lib/appwrite/enums/execution_trigger.rb b/lib/appwrite/enums/execution_trigger.rb index 59428c6d..f5d58520 100644 --- a/lib/appwrite/enums/execution_trigger.rb +++ b/lib/appwrite/enums/execution_trigger.rb @@ -4,6 +4,7 @@ module ExecutionTrigger HTTP = 'http' SCHEDULE = 'schedule' EVENT = 'event' + EMAIL = 'email' end end end diff --git a/lib/appwrite/enums/organization_key_scopes.rb b/lib/appwrite/enums/organization_key_scopes.rb deleted file mode 100644 index 9a8c7aa3..00000000 --- a/lib/appwrite/enums/organization_key_scopes.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Appwrite - module Enums - module OrganizationKeyScopes - PROJECTS_READ = 'projects.read' - PROJECTS_WRITE = 'projects.write' - DEVKEYS_READ = 'devKeys.read' - 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' - ORGANIZATION_WRITE = 'organization.write' - DOMAINS_READ = 'domains.read' - DOMAINS_WRITE = 'domains.write' - KEYS_READ = 'keys.read' - KEYS_WRITE = 'keys.write' - end - end -end diff --git a/lib/appwrite/enums/proxy_rule_protocol.rb b/lib/appwrite/enums/proxy_rule_protocol.rb new file mode 100644 index 00000000..4c1fd4a1 --- /dev/null +++ b/lib/appwrite/enums/proxy_rule_protocol.rb @@ -0,0 +1,8 @@ +module Appwrite + module Enums + module ProxyRuleProtocol + HTTP = 'http' + SMTP = 'smtp' + end + end +end diff --git a/lib/appwrite/models/activity_event.rb b/lib/appwrite/models/activity_event.rb index 34699a2b..ed92c606 100644 --- a/lib/appwrite/models/activity_event.rb +++ b/lib/appwrite/models/activity_event.rb @@ -96,6 +96,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "actorType" => "", "actorId" => "", "actorEmail" => "", "actorName" => "", "resourceParent" => "", "resourceType" => "", "resourceId" => "", "resource" => "", "event" => "", "userAgent" => "", "ip" => "", "mode" => "", "country" => "", "continentCode" => "", "city" => "", "subdivisions" => "", "isp" => "", "autonomousSystemNumber" => "", "autonomousSystemOrganization" => "", "connectionType" => "", "connectionUsageType" => "", "connectionOrganization" => "", "time" => "", "projectId" => "", "teamId" => "", "hostname" => "", "sdk" => "", "sdkVersion" => "" }.merge(map) ActivityEvent.new( id: map["$id"], actor_type: map["actorType"], diff --git a/lib/appwrite/models/activity_event_list.rb b/lib/appwrite/models/activity_event_list.rb index 6c8ebfe3..214f21cd 100644 --- a/lib/appwrite/models/activity_event_list.rb +++ b/lib/appwrite/models/activity_event_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "events" => [] }.merge(map) ActivityEventList.new( total: map["total"], events: map["events"].map { |it| ActivityEvent.from(map: it) } diff --git a/lib/appwrite/models/additional_resource.rb b/lib/appwrite/models/additional_resource.rb index 54d3ad41..fea38e38 100644 --- a/lib/appwrite/models/additional_resource.rb +++ b/lib/appwrite/models/additional_resource.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "unit" => "", "currency" => "", "price" => 0, "value" => 0, "invoiceDesc" => "" }.merge(map) AdditionalResource.new( name: map["name"], unit: map["unit"], diff --git a/lib/appwrite/models/algo_argon2.rb b/lib/appwrite/models/algo_argon2.rb index d2413e72..213dc487 100644 --- a/lib/appwrite/models/algo_argon2.rb +++ b/lib/appwrite/models/algo_argon2.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "type" => "argon2", "memoryCost" => 0, "timeCost" => 0, "threads" => 0 }.merge(map) AlgoArgon2.new( type: map["type"], memory_cost: map["memoryCost"], diff --git a/lib/appwrite/models/algo_bcrypt.rb b/lib/appwrite/models/algo_bcrypt.rb index 0407c819..13c7758c 100644 --- a/lib/appwrite/models/algo_bcrypt.rb +++ b/lib/appwrite/models/algo_bcrypt.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "bcrypt" }.merge(map) AlgoBcrypt.new( type: map["type"] ) diff --git a/lib/appwrite/models/algo_md5.rb b/lib/appwrite/models/algo_md5.rb index d7f315c9..0a79ce23 100644 --- a/lib/appwrite/models/algo_md5.rb +++ b/lib/appwrite/models/algo_md5.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "md5" }.merge(map) AlgoMd5.new( type: map["type"] ) diff --git a/lib/appwrite/models/algo_phpass.rb b/lib/appwrite/models/algo_phpass.rb index 496d2065..2a44c3b6 100644 --- a/lib/appwrite/models/algo_phpass.rb +++ b/lib/appwrite/models/algo_phpass.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "phpass" }.merge(map) AlgoPhpass.new( type: map["type"] ) diff --git a/lib/appwrite/models/algo_scrypt.rb b/lib/appwrite/models/algo_scrypt.rb index 7128bb2f..8cf555c8 100644 --- a/lib/appwrite/models/algo_scrypt.rb +++ b/lib/appwrite/models/algo_scrypt.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "type" => "scrypt", "costCpu" => 8, "costMemory" => 14, "costParallel" => 1, "length" => 64 }.merge(map) AlgoScrypt.new( type: map["type"], cost_cpu: map["costCpu"], diff --git a/lib/appwrite/models/algo_scrypt_modified.rb b/lib/appwrite/models/algo_scrypt_modified.rb index 8862154c..3a27d34d 100644 --- a/lib/appwrite/models/algo_scrypt_modified.rb +++ b/lib/appwrite/models/algo_scrypt_modified.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "type" => "scryptMod", "salt" => "", "saltSeparator" => "", "signerKey" => "" }.merge(map) AlgoScryptModified.new( type: map["type"], salt: map["salt"], diff --git a/lib/appwrite/models/algo_sha.rb b/lib/appwrite/models/algo_sha.rb index bd227d57..16dc3be8 100644 --- a/lib/appwrite/models/algo_sha.rb +++ b/lib/appwrite/models/algo_sha.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "sha" }.merge(map) AlgoSha.new( type: map["type"] ) diff --git a/lib/appwrite/models/app.rb b/lib/appwrite/models/app.rb index 5123fbd9..13af49c0 100644 --- a/lib/appwrite/models/app.rb +++ b/lib/appwrite/models/app.rb @@ -87,6 +87,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "description" => "", "clientUri" => "", "logoUri" => "", "privacyPolicyUrl" => "", "termsUrl" => "", "contacts" => [], "tagline" => "", "tags" => [], "labels" => [], "images" => [], "supportUrl" => "", "dataDeletionUrl" => "", "redirectUris" => [], "postLogoutRedirectUris" => [], "enabled" => true, "type" => "confidential", "deviceFlow" => false, "teamId" => "", "userId" => "", "installationScopes" => [], "installationRedirectUrl" => "", "secrets" => [] }.merge(map) App.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_installation.rb b/lib/appwrite/models/app_installation.rb index 32a12a3e..f5b42e6a 100644 --- a/lib/appwrite/models/app_installation.rb +++ b/lib/appwrite/models/app_installation.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "teamId" => "", "scopes" => [], "authorizationDetails" => [], "createdById" => "", "createdByName" => "" }.merge(map) AppInstallation.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_installation_list.rb b/lib/appwrite/models/app_installation_list.rb index d59981cc..0efb5504 100644 --- a/lib/appwrite/models/app_installation_list.rb +++ b/lib/appwrite/models/app_installation_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "installations" => [] }.merge(map) AppInstallationList.new( total: map["total"], installations: map["installations"].map { |it| AppInstallation.from(map: it) } diff --git a/lib/appwrite/models/app_key.rb b/lib/appwrite/models/app_key.rb index f1a457f8..ad9d93c0 100644 --- a/lib/appwrite/models/app_key.rb +++ b/lib/appwrite/models/app_key.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "secret" => "", "hint" => "", "createdById" => "", "createdByName" => "" }.merge(map) AppKey.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_key_list.rb b/lib/appwrite/models/app_key_list.rb index 3ec9ecd7..7d2af88f 100644 --- a/lib/appwrite/models/app_key_list.rb +++ b/lib/appwrite/models/app_key_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "keys" => [] }.merge(map) AppKeyList.new( total: map["total"], keys: map["keys"].map { |it| AppKey.from(map: it) } diff --git a/lib/appwrite/models/app_scope.rb b/lib/appwrite/models/app_scope.rb index c12c0ccc..bd068e37 100644 --- a/lib/appwrite/models/app_scope.rb +++ b/lib/appwrite/models/app_scope.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "value" => "", "description" => "", "type" => "", "category" => "", "deprecated" => false }.merge(map) AppScope.new( value: map["value"], description: map["description"], diff --git a/lib/appwrite/models/app_scope_list.rb b/lib/appwrite/models/app_scope_list.rb index 8a7b772b..82426a7c 100644 --- a/lib/appwrite/models/app_scope_list.rb +++ b/lib/appwrite/models/app_scope_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "scopes" => [] }.merge(map) AppScopeList.new( total: map["total"], scopes: map["scopes"].map { |it| AppScope.from(map: it) } diff --git a/lib/appwrite/models/app_secret.rb b/lib/appwrite/models/app_secret.rb index 4170d66c..f65846a8 100644 --- a/lib/appwrite/models/app_secret.rb +++ b/lib/appwrite/models/app_secret.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "secret" => "", "hint" => "", "createdById" => "", "createdByName" => "" }.merge(map) AppSecret.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_secret_list.rb b/lib/appwrite/models/app_secret_list.rb index d4da1d58..0f1b1a5b 100644 --- a/lib/appwrite/models/app_secret_list.rb +++ b/lib/appwrite/models/app_secret_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "secrets" => [] }.merge(map) AppSecretList.new( total: map["total"], secrets: map["secrets"].map { |it| AppSecret.from(map: it) } diff --git a/lib/appwrite/models/app_secret_plaintext.rb b/lib/appwrite/models/app_secret_plaintext.rb index d36c260a..de5ea6ec 100644 --- a/lib/appwrite/models/app_secret_plaintext.rb +++ b/lib/appwrite/models/app_secret_plaintext.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "secret" => "", "hint" => "", "createdById" => "", "createdByName" => "" }.merge(map) AppSecretPlaintext.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/apps_list.rb b/lib/appwrite/models/apps_list.rb index 354957bc..cff5c27a 100644 --- a/lib/appwrite/models/apps_list.rb +++ b/lib/appwrite/models/apps_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "apps" => [] }.merge(map) AppsList.new( total: map["total"], apps: map["apps"].map { |it| App.from(map: it) } diff --git a/lib/appwrite/models/attribute_bigint.rb b/lib/appwrite/models/attribute_bigint.rb index b2286d7a..3de6d81a 100644 --- a/lib/appwrite/models/attribute_bigint.rb +++ b/lib/appwrite/models/attribute_bigint.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeBigint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_boolean.rb b/lib/appwrite/models/attribute_boolean.rb index 145da450..3f594d2c 100644 --- a/lib/appwrite/models/attribute_boolean.rb +++ b/lib/appwrite/models/attribute_boolean.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeBoolean.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_datetime.rb b/lib/appwrite/models/attribute_datetime.rb index 2cd2387e..7d19713e 100644 --- a/lib/appwrite/models/attribute_datetime.rb +++ b/lib/appwrite/models/attribute_datetime.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeDatetime.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_email.rb b/lib/appwrite/models/attribute_email.rb index d3dc9589..808e07ce 100644 --- a/lib/appwrite/models/attribute_email.rb +++ b/lib/appwrite/models/attribute_email.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "email" }.merge(map) AttributeEmail.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_enum.rb b/lib/appwrite/models/attribute_enum.rb index 758db16d..5eadaece 100644 --- a/lib/appwrite/models/attribute_enum.rb +++ b/lib/appwrite/models/attribute_enum.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "elements" => [], "format" => "enum" }.merge(map) AttributeEnum.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_float.rb b/lib/appwrite/models/attribute_float.rb index fd4c2581..85fad7b5 100644 --- a/lib/appwrite/models/attribute_float.rb +++ b/lib/appwrite/models/attribute_float.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeFloat.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_integer.rb b/lib/appwrite/models/attribute_integer.rb index 0707b347..aeebffff 100644 --- a/lib/appwrite/models/attribute_integer.rb +++ b/lib/appwrite/models/attribute_integer.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeInteger.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_ip.rb b/lib/appwrite/models/attribute_ip.rb index 4ac5e3b2..09f75337 100644 --- a/lib/appwrite/models/attribute_ip.rb +++ b/lib/appwrite/models/attribute_ip.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "ip" }.merge(map) AttributeIp.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_line.rb b/lib/appwrite/models/attribute_line.rb index 23cda309..ca22747e 100644 --- a/lib/appwrite/models/attribute_line.rb +++ b/lib/appwrite/models/attribute_line.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeLine.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_list.rb b/lib/appwrite/models/attribute_list.rb index 4aafafbc..dad98609 100644 --- a/lib/appwrite/models/attribute_list.rb +++ b/lib/appwrite/models/attribute_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "attributes" => [] }.merge(map) AttributeList.new( total: map["total"], attributes: map["attributes"] diff --git a/lib/appwrite/models/attribute_longtext.rb b/lib/appwrite/models/attribute_longtext.rb index 55922b0a..40400db9 100644 --- a/lib/appwrite/models/attribute_longtext.rb +++ b/lib/appwrite/models/attribute_longtext.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeLongtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_mediumtext.rb b/lib/appwrite/models/attribute_mediumtext.rb index 0dea9331..cc8c0cd3 100644 --- a/lib/appwrite/models/attribute_mediumtext.rb +++ b/lib/appwrite/models/attribute_mediumtext.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeMediumtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_object.rb b/lib/appwrite/models/attribute_object.rb index ab85153d..01396202 100644 --- a/lib/appwrite/models/attribute_object.rb +++ b/lib/appwrite/models/attribute_object.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeObject.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_point.rb b/lib/appwrite/models/attribute_point.rb index b236cb17..f1dd0517 100644 --- a/lib/appwrite/models/attribute_point.rb +++ b/lib/appwrite/models/attribute_point.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributePoint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_polygon.rb b/lib/appwrite/models/attribute_polygon.rb index 44ce447a..b5298101 100644 --- a/lib/appwrite/models/attribute_polygon.rb +++ b/lib/appwrite/models/attribute_polygon.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributePolygon.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_relationship.rb b/lib/appwrite/models/attribute_relationship.rb index 9b8da81c..fe8b276c 100644 --- a/lib/appwrite/models/attribute_relationship.rb +++ b/lib/appwrite/models/attribute_relationship.rb @@ -51,6 +51,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "relationType" => "", "twoWay" => false, "twoWayKey" => "", "onDelete" => "restrict", "side" => "" }.merge(map) AttributeRelationship.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_string.rb b/lib/appwrite/models/attribute_string.rb index e5e27203..2f3499ca 100644 --- a/lib/appwrite/models/attribute_string.rb +++ b/lib/appwrite/models/attribute_string.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) AttributeString.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_text.rb b/lib/appwrite/models/attribute_text.rb index 3997ad15..9047c342 100644 --- a/lib/appwrite/models/attribute_text.rb +++ b/lib/appwrite/models/attribute_text.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeText.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_url.rb b/lib/appwrite/models/attribute_url.rb index 2353dc79..e6d62685 100644 --- a/lib/appwrite/models/attribute_url.rb +++ b/lib/appwrite/models/attribute_url.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "url" }.merge(map) AttributeUrl.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_varchar.rb b/lib/appwrite/models/attribute_varchar.rb index 3720b0e0..fe438fea 100644 --- a/lib/appwrite/models/attribute_varchar.rb +++ b/lib/appwrite/models/attribute_varchar.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) AttributeVarchar.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_vector.rb b/lib/appwrite/models/attribute_vector.rb index 3954eefd..8ea3f9d0 100644 --- a/lib/appwrite/models/attribute_vector.rb +++ b/lib/appwrite/models/attribute_vector.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) AttributeVector.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/backup_archive.rb b/lib/appwrite/models/backup_archive.rb index 71ea159d..20852c2d 100644 --- a/lib/appwrite/models/backup_archive.rb +++ b/lib/appwrite/models/backup_archive.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "policyId" => "", "status" => "", "migrationId" => "", "services" => [], "resources" => [] }.merge(map) BackupArchive.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/backup_archive_list.rb b/lib/appwrite/models/backup_archive_list.rb index 9c0cc7cc..848d268c 100644 --- a/lib/appwrite/models/backup_archive_list.rb +++ b/lib/appwrite/models/backup_archive_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "archives" => [] }.merge(map) BackupArchiveList.new( total: map["total"], archives: map["archives"].map { |it| BackupArchive.from(map: it) } diff --git a/lib/appwrite/models/backup_policy.rb b/lib/appwrite/models/backup_policy.rb index 6e8e0376..acd93e45 100644 --- a/lib/appwrite/models/backup_policy.rb +++ b/lib/appwrite/models/backup_policy.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "name" => "", "$createdAt" => "", "$updatedAt" => "", "services" => [], "resources" => [], "retention" => 1, "schedule" => "0 * * * *", "type" => "full", "enabled" => false }.merge(map) BackupPolicy.new( id: map["$id"], name: map["name"], diff --git a/lib/appwrite/models/backup_policy_list.rb b/lib/appwrite/models/backup_policy_list.rb index d5de4a5d..294aa8ca 100644 --- a/lib/appwrite/models/backup_policy_list.rb +++ b/lib/appwrite/models/backup_policy_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "policies" => [] }.merge(map) BackupPolicyList.new( total: map["total"], policies: map["policies"].map { |it| BackupPolicy.from(map: it) } diff --git a/lib/appwrite/models/backup_restoration.rb b/lib/appwrite/models/backup_restoration.rb index 61eb62f4..99ac22c0 100644 --- a/lib/appwrite/models/backup_restoration.rb +++ b/lib/appwrite/models/backup_restoration.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "archiveId" => "", "policyId" => "", "status" => "", "migrationId" => "", "services" => [], "resources" => [], "options" => {} }.merge(map) BackupRestoration.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/backup_restoration_list.rb b/lib/appwrite/models/backup_restoration_list.rb index 671e135b..8f6fb521 100644 --- a/lib/appwrite/models/backup_restoration_list.rb +++ b/lib/appwrite/models/backup_restoration_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "restorations" => [] }.merge(map) BackupRestorationList.new( total: map["total"], restorations: map["restorations"].map { |it| BackupRestoration.from(map: it) } diff --git a/lib/appwrite/models/billing_limits.rb b/lib/appwrite/models/billing_limits.rb index ef61643b..8eefd941 100644 --- a/lib/appwrite/models/billing_limits.rb +++ b/lib/appwrite/models/billing_limits.rb @@ -13,14 +13,14 @@ class BillingLimits attr_reader :budget_limit def initialize( - bandwidth:, - storage:, - users:, - executions:, - gb_hours:, - image_transformations:, - auth_phone:, - budget_limit: + bandwidth: 0, + storage: 0, + users: 0, + executions: 0, + gb_hours: 0, + image_transformations: 0, + auth_phone: 0, + budget_limit: 0 ) @bandwidth = bandwidth @storage = storage diff --git a/lib/appwrite/models/billing_plan.rb b/lib/appwrite/models/billing_plan.rb index 2a5b6644..80c8a90a 100644 --- a/lib/appwrite/models/billing_plan.rb +++ b/lib/appwrite/models/billing_plan.rb @@ -90,7 +90,7 @@ def initialize( storage:, image_transformations:, screenshots_generated:, - members:, + members: 0, webhooks:, waf_rules:, environments:, @@ -115,10 +115,10 @@ def initialize( topics:, auth_phone:, domains:, - activity_logs:, + activity_logs: 1, usage_logs:, - usage_logs_intervals:, - usage_aggregate_only_metrics:, + usage_logs_intervals: ["15m", "1h", "1d"], + usage_aggregate_only_metrics: [], project_inactivity_days:, alert_limit:, usage:, @@ -128,7 +128,7 @@ def initialize( email_branding:, requires_payment_method:, requires_billing_address:, - eligible_countries:, + eligible_countries: [], is_available:, self_service:, premium_support:, @@ -142,10 +142,10 @@ def initialize( supports_free_email_validation:, supports_corporate_email_validation:, supports_project_specific_roles:, - backups_enabled:, + backups_enabled: true, usage_per_project:, supported_addons:, - backup_policies:, + backup_policies: 0, deployment_size:, build_size:, functions_interval_minimum:, @@ -234,6 +234,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "name" => "", "desc" => "", "order" => 0, "price" => 0, "trial" => 0, "bandwidth" => 0, "storage" => 0, "imageTransformations" => 0, "screenshotsGenerated" => 0, "webhooks" => 0, "wafRules" => 0, "environments" => 0, "projects" => 0, "platforms" => 0, "users" => 0, "teams" => 0, "databases" => 0, "databasesReads" => 0, "databasesWrites" => 0, "databasesBatchSize" => 0, "buckets" => 0, "fileSize" => 0, "functions" => 0, "sites" => 0, "executions" => 0, "executionsRetentionCount" => 1000, "GBHours" => 0, "realtime" => 0, "realtimeMessages" => 0, "messages" => 0, "topics" => 0, "authPhone" => 0, "domains" => 0, "usageLogs" => 0, "projectInactivityDays" => 0, "alertLimit" => 80, "budgetCapEnabled" => false, "customSmtp" => false, "emailBranding" => false, "requiresPaymentMethod" => true, "requiresBillingAddress" => false, "isAvailable" => true, "selfService" => true, "premiumSupport" => true, "budgeting" => true, "supportsMockNumbers" => true, "supportsOrganizationRoles" => true, "supportsCredits" => false, "supportsDedicatedDatabases" => false, "supportsDisposableEmailValidation" => false, "supportsCanonicalEmailValidation" => false, "supportsFreeEmailValidation" => false, "supportsCorporateEmailValidation" => false, "supportsProjectSpecificRoles" => false, "usagePerProject" => true, "deploymentSize" => 0, "buildSize" => 0, "functionsIntervalMinimum" => 0, "databasesAllowEncrypt" => false, "databaseComputeCredit" => 0 }.merge(map) BillingPlan.new( id: map["$id"], name: map["name"], @@ -276,7 +277,7 @@ def self.from(map:) usage_aggregate_only_metrics: map["usageAggregateOnlyMetrics"], project_inactivity_days: map["projectInactivityDays"], alert_limit: map["alertLimit"], - usage: UsageBillingPlan.from(map: map["usage"]), + usage: map["usage"].nil? ? nil : UsageBillingPlan.from(map: map["usage"]), addons: BillingPlanAddon.from(map: map["addons"]), budget_cap_enabled: map["budgetCapEnabled"], custom_smtp: map["customSmtp"], @@ -356,7 +357,7 @@ def to_map "usageAggregateOnlyMetrics": @usage_aggregate_only_metrics, "projectInactivityDays": @project_inactivity_days, "alertLimit": @alert_limit, - "usage": @usage.to_map, + "usage": @usage&.to_map, "addons": @addons.to_map, "budgetCapEnabled": @budget_cap_enabled, "customSmtp": @custom_smtp, @@ -397,7 +398,6 @@ def to_map def validate_group(group) valid_group = [ - Appwrite::Enums::BillingPlanGroup::STARTER, Appwrite::Enums::BillingPlanGroup::FREE, Appwrite::Enums::BillingPlanGroup::START, Appwrite::Enums::BillingPlanGroup::PRO, diff --git a/lib/appwrite/models/billing_plan_addon_details.rb b/lib/appwrite/models/billing_plan_addon_details.rb index 3dc5e285..106badcc 100644 --- a/lib/appwrite/models/billing_plan_addon_details.rb +++ b/lib/appwrite/models/billing_plan_addon_details.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "supported" => false, "planIncluded" => 0, "limit" => 0, "type" => "numeric", "price" => 0, "value" => 0, "invoiceDesc" => "" }.merge(map) BillingPlanAddonDetails.new( supported: map["supported"], plan_included: map["planIncluded"], diff --git a/lib/appwrite/models/billing_plan_dedicated_database_limits.rb b/lib/appwrite/models/billing_plan_dedicated_database_limits.rb index 3e179ad2..a6c6bb7c 100644 --- a/lib/appwrite/models/billing_plan_dedicated_database_limits.rb +++ b/lib/appwrite/models/billing_plan_dedicated_database_limits.rb @@ -24,25 +24,25 @@ class BillingPlanDedicatedDatabaseLimits attr_reader :allowed_sync_modes def initialize( - min_cpu:, - max_cpu:, - min_memory_mb:, - max_memory_mb:, - min_storage_gb:, - max_storage_gb:, - max_replicas:, - max_connections:, - max_ip_allowlist_size:, - max_extensions:, - max_backup_retention_days:, - max_pitr_retention_days:, - max_sql_api_max_rows:, - max_sql_api_max_bytes:, - max_sql_api_timeout_seconds:, - max_sql_api_allowed_statements:, - allowed_sql_statements:, - allowed_storage_classes:, - allowed_sync_modes: + min_cpu: 0, + max_cpu: 0, + min_memory_mb: 0, + max_memory_mb: 0, + min_storage_gb: 0, + max_storage_gb: 0, + max_replicas: 0, + max_connections: 0, + max_ip_allowlist_size: 0, + max_extensions: 0, + max_backup_retention_days: 0, + max_pitr_retention_days: 0, + max_sql_api_max_rows: 0, + max_sql_api_max_bytes: 0, + max_sql_api_timeout_seconds: 0, + max_sql_api_allowed_statements: 0, + allowed_sql_statements: [], + allowed_storage_classes: [], + allowed_sync_modes: [] ) @min_cpu = min_cpu @max_cpu = max_cpu diff --git a/lib/appwrite/models/billing_plan_limits.rb b/lib/appwrite/models/billing_plan_limits.rb index 999a55bf..89f5235c 100644 --- a/lib/appwrite/models/billing_plan_limits.rb +++ b/lib/appwrite/models/billing_plan_limits.rb @@ -7,8 +7,8 @@ class BillingPlanLimits attr_reader :daily_credits def initialize( - credits:, - daily_credits: + credits: 0, + daily_credits: 0 ) @credits = credits @daily_credits = daily_credits diff --git a/lib/appwrite/models/billing_plan_supported_addons.rb b/lib/appwrite/models/billing_plan_supported_addons.rb index ea2d8078..430878ac 100644 --- a/lib/appwrite/models/billing_plan_supported_addons.rb +++ b/lib/appwrite/models/billing_plan_supported_addons.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "baa" => false, "premiumGeoDB" => false, "premiumGeoDBOrg" => false }.merge(map) BillingPlanSupportedAddons.new( baa: map["baa"], premium_geo_db: map["premiumGeoDB"], diff --git a/lib/appwrite/models/block.rb b/lib/appwrite/models/block.rb index 4a1c81a6..d022ac08 100644 --- a/lib/appwrite/models/block.rb +++ b/lib/appwrite/models/block.rb @@ -7,53 +7,30 @@ class Block attr_reader :resource_type attr_reader :resource_id attr_reader :mode - attr_reader :reason attr_reader :expired_at - attr_reader :project_name - attr_reader :region - attr_reader :organization_name - attr_reader :organization_id - attr_reader :billing_plan def initialize( created_at:, resource_type:, resource_id:, mode:, - reason:, - expired_at:, - project_name:, - region:, - organization_name:, - organization_id:, - billing_plan: + expired_at: ) @created_at = created_at @resource_type = resource_type @resource_id = resource_id @mode = mode - @reason = reason @expired_at = expired_at - @project_name = project_name - @region = region - @organization_name = organization_name - @organization_id = organization_id - @billing_plan = billing_plan end def self.from(map:) + map = { "$createdAt" => "", "resourceType" => "", "resourceId" => "", "mode" => "full" }.merge(map) Block.new( created_at: map["$createdAt"], resource_type: map["resourceType"], resource_id: map["resourceId"], mode: map["mode"], - reason: map["reason"], - expired_at: map["expiredAt"], - project_name: map["projectName"], - region: map["region"], - organization_name: map["organizationName"], - organization_id: map["organizationId"], - billing_plan: map["billingPlan"] + expired_at: map["expiredAt"] ) end @@ -63,13 +40,7 @@ def to_map "resourceType": @resource_type, "resourceId": @resource_id, "mode": @mode, - "reason": @reason, - "expiredAt": @expired_at, - "projectName": @project_name, - "region": @region, - "organizationName": @organization_name, - "organizationId": @organization_id, - "billingPlan": @billing_plan + "expiredAt": @expired_at } end end diff --git a/lib/appwrite/models/bucket.rb b/lib/appwrite/models/bucket.rb index c7e8af99..4729a406 100644 --- a/lib/appwrite/models/bucket.rb +++ b/lib/appwrite/models/bucket.rb @@ -51,6 +51,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "fileSecurity" => false, "name" => "", "enabled" => true, "maximumFileSize" => 0, "allowedFileExtensions" => [], "compression" => "", "encryption" => true, "antivirus" => true, "transformations" => true, "totalSize" => 0 }.merge(map) Bucket.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/bucket_list.rb b/lib/appwrite/models/bucket_list.rb index 7d3c15a2..4912786b 100644 --- a/lib/appwrite/models/bucket_list.rb +++ b/lib/appwrite/models/bucket_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "buckets" => [] }.merge(map) BucketList.new( total: map["total"], buckets: map["buckets"].map { |it| Bucket.from(map: it) } diff --git a/lib/appwrite/models/collection.rb b/lib/appwrite/models/collection.rb index 9e270f29..d0319ddd 100644 --- a/lib/appwrite/models/collection.rb +++ b/lib/appwrite/models/collection.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "databaseId" => "", "name" => "", "enabled" => true, "documentSecurity" => false, "attributes" => [], "indexes" => [], "bytesMax" => 0, "bytesUsed" => 0 }.merge(map) Collection.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/collection_list.rb b/lib/appwrite/models/collection_list.rb index e1e42d26..31b8f1b8 100644 --- a/lib/appwrite/models/collection_list.rb +++ b/lib/appwrite/models/collection_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "collections" => [] }.merge(map) CollectionList.new( total: map["total"], collections: map["collections"].map { |it| Collection.from(map: it) } diff --git a/lib/appwrite/models/column_bigint.rb b/lib/appwrite/models/column_bigint.rb index 3dfa471a..827dc9b0 100644 --- a/lib/appwrite/models/column_bigint.rb +++ b/lib/appwrite/models/column_bigint.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnBigint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_boolean.rb b/lib/appwrite/models/column_boolean.rb index 83baf4a5..24447056 100644 --- a/lib/appwrite/models/column_boolean.rb +++ b/lib/appwrite/models/column_boolean.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnBoolean.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_datetime.rb b/lib/appwrite/models/column_datetime.rb index 60122665..dc77c1b9 100644 --- a/lib/appwrite/models/column_datetime.rb +++ b/lib/appwrite/models/column_datetime.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnDatetime.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_email.rb b/lib/appwrite/models/column_email.rb index 574e47e5..94694463 100644 --- a/lib/appwrite/models/column_email.rb +++ b/lib/appwrite/models/column_email.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "email" }.merge(map) ColumnEmail.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_enum.rb b/lib/appwrite/models/column_enum.rb index 0f2bd545..6ef78955 100644 --- a/lib/appwrite/models/column_enum.rb +++ b/lib/appwrite/models/column_enum.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "elements" => [], "format" => "enum" }.merge(map) ColumnEnum.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_float.rb b/lib/appwrite/models/column_float.rb index 3c06c690..3260c161 100644 --- a/lib/appwrite/models/column_float.rb +++ b/lib/appwrite/models/column_float.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnFloat.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_index.rb b/lib/appwrite/models/column_index.rb index 478d4c23..3b4f89bc 100644 --- a/lib/appwrite/models/column_index.rb +++ b/lib/appwrite/models/column_index.rb @@ -24,7 +24,7 @@ def initialize( error:, columns:, lengths:, - orders: + orders: [] ) @id = id @created_at = created_at @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "key" => "", "type" => "", "status" => "", "error" => "", "columns" => [], "lengths" => [] }.merge(map) ColumnIndex.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/column_index_list.rb b/lib/appwrite/models/column_index_list.rb index 9278fd40..5aacf564 100644 --- a/lib/appwrite/models/column_index_list.rb +++ b/lib/appwrite/models/column_index_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "indexes" => [] }.merge(map) ColumnIndexList.new( total: map["total"], indexes: map["indexes"].map { |it| ColumnIndex.from(map: it) } diff --git a/lib/appwrite/models/column_integer.rb b/lib/appwrite/models/column_integer.rb index 0a71c44f..d58db0f7 100644 --- a/lib/appwrite/models/column_integer.rb +++ b/lib/appwrite/models/column_integer.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnInteger.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_ip.rb b/lib/appwrite/models/column_ip.rb index 3d4f6551..12b7ff0d 100644 --- a/lib/appwrite/models/column_ip.rb +++ b/lib/appwrite/models/column_ip.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "ip" }.merge(map) ColumnIp.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_line.rb b/lib/appwrite/models/column_line.rb index f8a14bf0..2ed8600e 100644 --- a/lib/appwrite/models/column_line.rb +++ b/lib/appwrite/models/column_line.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnLine.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_list.rb b/lib/appwrite/models/column_list.rb index 8d239ddf..a635a9b4 100644 --- a/lib/appwrite/models/column_list.rb +++ b/lib/appwrite/models/column_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "columns" => [] }.merge(map) ColumnList.new( total: map["total"], columns: map["columns"] diff --git a/lib/appwrite/models/column_longtext.rb b/lib/appwrite/models/column_longtext.rb index 5a112087..138b6315 100644 --- a/lib/appwrite/models/column_longtext.rb +++ b/lib/appwrite/models/column_longtext.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnLongtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_mediumtext.rb b/lib/appwrite/models/column_mediumtext.rb index c5b465c9..57fb8e40 100644 --- a/lib/appwrite/models/column_mediumtext.rb +++ b/lib/appwrite/models/column_mediumtext.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnMediumtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_point.rb b/lib/appwrite/models/column_point.rb index 34e5cf0e..b4f8cc75 100644 --- a/lib/appwrite/models/column_point.rb +++ b/lib/appwrite/models/column_point.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnPoint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_polygon.rb b/lib/appwrite/models/column_polygon.rb index 82f39732..b908f56a 100644 --- a/lib/appwrite/models/column_polygon.rb +++ b/lib/appwrite/models/column_polygon.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnPolygon.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_relationship.rb b/lib/appwrite/models/column_relationship.rb index c34643ea..22effc88 100644 --- a/lib/appwrite/models/column_relationship.rb +++ b/lib/appwrite/models/column_relationship.rb @@ -51,6 +51,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "relationType" => "", "twoWay" => false, "twoWayKey" => "", "onDelete" => "restrict", "side" => "" }.merge(map) ColumnRelationship.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_string.rb b/lib/appwrite/models/column_string.rb index 6e08f2f5..fea53cf3 100644 --- a/lib/appwrite/models/column_string.rb +++ b/lib/appwrite/models/column_string.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) ColumnString.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_text.rb b/lib/appwrite/models/column_text.rb index c3c7afb0..a72bd581 100644 --- a/lib/appwrite/models/column_text.rb +++ b/lib/appwrite/models/column_text.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnText.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_url.rb b/lib/appwrite/models/column_url.rb index 11829a7d..4cd93199 100644 --- a/lib/appwrite/models/column_url.rb +++ b/lib/appwrite/models/column_url.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "url" }.merge(map) ColumnUrl.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_varchar.rb b/lib/appwrite/models/column_varchar.rb index 1a1083d7..bf84a3e8 100644 --- a/lib/appwrite/models/column_varchar.rb +++ b/lib/appwrite/models/column_varchar.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) ColumnVarchar.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/continent.rb b/lib/appwrite/models/continent.rb index 861ec29f..64190bbc 100644 --- a/lib/appwrite/models/continent.rb +++ b/lib/appwrite/models/continent.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "code" => "" }.merge(map) Continent.new( name: map["name"], code: map["code"] diff --git a/lib/appwrite/models/continent_list.rb b/lib/appwrite/models/continent_list.rb index a5312493..f6a8c658 100644 --- a/lib/appwrite/models/continent_list.rb +++ b/lib/appwrite/models/continent_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "continents" => [] }.merge(map) ContinentList.new( total: map["total"], continents: map["continents"].map { |it| Continent.from(map: it) } diff --git a/lib/appwrite/models/country.rb b/lib/appwrite/models/country.rb index 07659799..7943e2cb 100644 --- a/lib/appwrite/models/country.rb +++ b/lib/appwrite/models/country.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "code" => "" }.merge(map) Country.new( name: map["name"], code: map["code"] diff --git a/lib/appwrite/models/country_list.rb b/lib/appwrite/models/country_list.rb index 1611dda7..7e537feb 100644 --- a/lib/appwrite/models/country_list.rb +++ b/lib/appwrite/models/country_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "countries" => [] }.merge(map) CountryList.new( total: map["total"], countries: map["countries"].map { |it| Country.from(map: it) } diff --git a/lib/appwrite/models/currency.rb b/lib/appwrite/models/currency.rb index b89e48ab..b9ebad26 100644 --- a/lib/appwrite/models/currency.rb +++ b/lib/appwrite/models/currency.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "symbol" => "", "name" => "", "symbolNative" => "", "decimalDigits" => 0, "rounding" => 0, "code" => "", "namePlural" => "" }.merge(map) Currency.new( symbol: map["symbol"], name: map["name"], diff --git a/lib/appwrite/models/currency_list.rb b/lib/appwrite/models/currency_list.rb index 53d23594..663aec21 100644 --- a/lib/appwrite/models/currency_list.rb +++ b/lib/appwrite/models/currency_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "currencies" => [] }.merge(map) CurrencyList.new( total: map["total"], currencies: map["currencies"].map { |it| Currency.from(map: it) } diff --git a/lib/appwrite/models/database.rb b/lib/appwrite/models/database.rb index d0408fc8..48d62333 100644 --- a/lib/appwrite/models/database.rb +++ b/lib/appwrite/models/database.rb @@ -54,6 +54,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "name" => "", "$createdAt" => "", "$updatedAt" => "", "enabled" => true, "type" => "legacy" }.merge(map) Database.new( id: map["$id"], name: map["name"], diff --git a/lib/appwrite/models/database_list.rb b/lib/appwrite/models/database_list.rb index 37c83aab..7b008d97 100644 --- a/lib/appwrite/models/database_list.rb +++ b/lib/appwrite/models/database_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "databases" => [] }.merge(map) DatabaseList.new( total: map["total"], databases: map["databases"].map { |it| Database.from(map: it) } diff --git a/lib/appwrite/models/database_migration.rb b/lib/appwrite/models/database_migration.rb index 75becc38..d0b4071d 100644 --- a/lib/appwrite/models/database_migration.rb +++ b/lib/appwrite/models/database_migration.rb @@ -60,6 +60,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "projectId" => "", "databaseId" => "", "specification" => "", "phase" => "pending", "attempt" => 0, "lastError" => "", "lagDocuments" => 0, "changelogWatermark" => 0, "verifiedAt" => "", "cutoverAt" => "", "soakUntil" => "", "autoCutover" => true, "cutoverRequested" => false, "paused" => false }.merge(map) DatabaseMigration.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/database_migration_list.rb b/lib/appwrite/models/database_migration_list.rb index 21730266..f42c1c2f 100644 --- a/lib/appwrite/models/database_migration_list.rb +++ b/lib/appwrite/models/database_migration_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "migrations" => [] }.merge(map) DatabaseMigrationList.new( total: map["total"], migrations: map["migrations"].map { |it| DatabaseMigration.from(map: it) } diff --git a/lib/appwrite/models/database_status.rb b/lib/appwrite/models/database_status.rb index f4a609c1..8fd8ca01 100644 --- a/lib/appwrite/models/database_status.rb +++ b/lib/appwrite/models/database_status.rb @@ -51,13 +51,14 @@ def initialize( end def self.from(map:) + map = { "health" => "unknown", "ready" => false, "engine" => "postgresql", "version" => "", "uptime" => 0, "syncMode" => "async", "syncDegraded" => false, "syncAcknowledgements" => 0, "syncStandbyCount" => 0, "replicas" => [], "volumes" => [] }.merge(map) DatabaseStatus.new( health: map["health"], ready: map["ready"], engine: map["engine"], version: map["version"], uptime: map["uptime"], - connections: DatabaseStatusConnections.from(map: map["connections"]), + connections: map["connections"].nil? ? nil : DatabaseStatusConnections.from(map: map["connections"]), sync_mode: map["syncMode"], effective_sync_mode: map["effectiveSyncMode"], sync_degraded: map["syncDegraded"], @@ -76,7 +77,7 @@ def to_map "engine": @engine, "version": @version, "uptime": @uptime, - "connections": @connections.to_map, + "connections": @connections&.to_map, "syncMode": @sync_mode, "effectiveSyncMode": @effective_sync_mode, "syncDegraded": @sync_degraded, diff --git a/lib/appwrite/models/database_status_connections.rb b/lib/appwrite/models/database_status_connections.rb index 623156df..22104215 100644 --- a/lib/appwrite/models/database_status_connections.rb +++ b/lib/appwrite/models/database_status_connections.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "current" => 0, "max" => 100 }.merge(map) DatabaseStatusConnections.new( current: map["current"], max: map["max"] diff --git a/lib/appwrite/models/database_status_replica.rb b/lib/appwrite/models/database_status_replica.rb index 7ed53873..5b499990 100644 --- a/lib/appwrite/models/database_status_replica.rb +++ b/lib/appwrite/models/database_status_replica.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "index" => 0, "role" => "unknown", "healthy" => false }.merge(map) DatabaseStatusReplica.new( index: map["index"], role: map["role"], diff --git a/lib/appwrite/models/database_status_volume.rb b/lib/appwrite/models/database_status_volume.rb index cd15505b..03c314eb 100644 --- a/lib/appwrite/models/database_status_volume.rb +++ b/lib/appwrite/models/database_status_volume.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "path" => "", "usedPercent" => "0%", "available" => "0GB", "mounted" => false }.merge(map) DatabaseStatusVolume.new( xpath: map["path"], used_percent: map["usedPercent"], diff --git a/lib/appwrite/models/dedicated_database.rb b/lib/appwrite/models/dedicated_database.rb index ca683b57..e9c87d7f 100644 --- a/lib/appwrite/models/dedicated_database.rb +++ b/lib/appwrite/models/dedicated_database.rb @@ -165,6 +165,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "projectId" => "", "name" => "", "version" => "", "specification" => "", "backend" => "", "hostname" => "", "connectionUser" => "", "connectionPassword" => "", "connectionString" => "", "ssl" => false, "status" => "provisioning", "containerStatus" => "", "lifecycleState" => "", "idleTimeoutMinutes" => 15, "cpu" => 500, "memory" => 512, "storage" => 10, "storageStatus" => "idle", "storageTargetGb" => 0, "storageClass" => "ssd", "storageMaxGb" => 0, "nodePool" => "", "replicas" => 0, "syncMode" => "", "networkMaxConnections" => 100, "networkIdleTimeoutSeconds" => 900, "networkIPAllowlist" => [], "backupEnabled" => true, "pitr" => true, "pitrRetentionDays" => 7, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, "storageAutoscalingMaxGb" => 0, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => false, "sqlApiEnabled" => true, "sqlApiAllowedStatements" => ["SELECT", "INSERT", "UPDATE", "DELETE"], "sqlApiMaxRows" => 10000, "sqlApiMaxBytes" => 10485760, "sqlApiTimeoutSeconds" => 30, "error" => "" }.merge(map) DedicatedDatabase.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/dedicated_database_backup.rb b/lib/appwrite/models/dedicated_database_backup.rb index f48b5d58..2fd522ed 100644 --- a/lib/appwrite/models/dedicated_database_backup.rb +++ b/lib/appwrite/models/dedicated_database_backup.rb @@ -60,6 +60,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "databaseId" => "", "projectId" => "", "policyId" => "", "trigger" => "manual", "type" => "full", "requestedType" => "", "fallbackReason" => "", "status" => "pending", "sizeBytes" => 0, "error" => "" }.merge(map) DedicatedDatabaseBackup.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/dedicated_database_backup_list.rb b/lib/appwrite/models/dedicated_database_backup_list.rb index 37d85ec0..c2c02187 100644 --- a/lib/appwrite/models/dedicated_database_backup_list.rb +++ b/lib/appwrite/models/dedicated_database_backup_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "backups" => [] }.merge(map) DedicatedDatabaseBackupList.new( total: map["total"], backups: map["backups"].map { |it| DedicatedDatabaseBackup.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_backup_storage.rb b/lib/appwrite/models/dedicated_database_backup_storage.rb index 3e1cb28b..aa2f1a2b 100644 --- a/lib/appwrite/models/dedicated_database_backup_storage.rb +++ b/lib/appwrite/models/dedicated_database_backup_storage.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "provider" => "", "bucket" => "", "region" => "", "prefix" => "backups/", "endpoint" => "" }.merge(map) DedicatedDatabaseBackupStorage.new( provider: map["provider"], bucket: map["bucket"], diff --git a/lib/appwrite/models/dedicated_database_branch.rb b/lib/appwrite/models/dedicated_database_branch.rb index 991728ca..52891c27 100644 --- a/lib/appwrite/models/dedicated_database_branch.rb +++ b/lib/appwrite/models/dedicated_database_branch.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "branchId" => "", "branchName" => "", "namespace" => "", "expiresAt" => 0, "host" => "", "database" => "", "username" => "", "password" => "", "ssl" => false, "engine" => "", "connectionString" => "" }.merge(map) DedicatedDatabaseBranch.new( branch_id: map["branchId"], branch_name: map["branchName"], diff --git a/lib/appwrite/models/dedicated_database_branch_list.rb b/lib/appwrite/models/dedicated_database_branch_list.rb index 106a3eb7..9ce8a978 100644 --- a/lib/appwrite/models/dedicated_database_branch_list.rb +++ b/lib/appwrite/models/dedicated_database_branch_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "branches" => [] }.merge(map) DedicatedDatabaseBranchList.new( total: map["total"], branches: map["branches"].map { |it| DedicatedDatabaseBranch.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_execution.rb b/lib/appwrite/models/dedicated_database_execution.rb index 49e247f3..8422db2d 100644 --- a/lib/appwrite/models/dedicated_database_execution.rb +++ b/lib/appwrite/models/dedicated_database_execution.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "rows" => [], "rowCount" => 0, "columns" => [], "durationMs" => 0, "truncated" => false, "bytes" => 0 }.merge(map) DedicatedDatabaseExecution.new( rows: map["rows"], row_count: map["rowCount"], diff --git a/lib/appwrite/models/dedicated_database_execution_column.rb b/lib/appwrite/models/dedicated_database_execution_column.rb index 4605650d..735dd40e 100644 --- a/lib/appwrite/models/dedicated_database_execution_column.rb +++ b/lib/appwrite/models/dedicated_database_execution_column.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "type" => "" }.merge(map) DedicatedDatabaseExecutionColumn.new( name: map["name"], type: map["type"] diff --git a/lib/appwrite/models/dedicated_database_extensions.rb b/lib/appwrite/models/dedicated_database_extensions.rb index 26c35a8e..559e09c2 100644 --- a/lib/appwrite/models/dedicated_database_extensions.rb +++ b/lib/appwrite/models/dedicated_database_extensions.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "installed" => [], "available" => [], "metadata" => [] }.merge(map) DedicatedDatabaseExtensions.new( installed: map["installed"], available: map["available"], diff --git a/lib/appwrite/models/dedicated_database_list.rb b/lib/appwrite/models/dedicated_database_list.rb index 3a66c939..79b8e45a 100644 --- a/lib/appwrite/models/dedicated_database_list.rb +++ b/lib/appwrite/models/dedicated_database_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "databases" => [] }.merge(map) DedicatedDatabaseList.new( total: map["total"], databases: map["databases"].map { |it| DedicatedDatabase.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_member.rb b/lib/appwrite/models/dedicated_database_member.rb index 8aaddc77..356dad04 100644 --- a/lib/appwrite/models/dedicated_database_member.rb +++ b/lib/appwrite/models/dedicated_database_member.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "role" => "unknown", "status" => "" }.merge(map) DedicatedDatabaseMember.new( id: map["$id"], role: map["role"], diff --git a/lib/appwrite/models/dedicated_database_operation.rb b/lib/appwrite/models/dedicated_database_operation.rb index bd6b53cf..112f0ada 100644 --- a/lib/appwrite/models/dedicated_database_operation.rb +++ b/lib/appwrite/models/dedicated_database_operation.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "databaseId" => "", "type" => "", "status" => "", "attempts" => 0, "errorCode" => "", "errorMessage" => "" }.merge(map) DedicatedDatabaseOperation.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/dedicated_database_operation_list.rb b/lib/appwrite/models/dedicated_database_operation_list.rb index d4985739..8b63a84b 100644 --- a/lib/appwrite/models/dedicated_database_operation_list.rb +++ b/lib/appwrite/models/dedicated_database_operation_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "operations" => [] }.merge(map) DedicatedDatabaseOperationList.new( total: map["total"], operations: map["operations"].map { |it| DedicatedDatabaseOperation.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_pitr_windows.rb b/lib/appwrite/models/dedicated_database_pitr_windows.rb index b80d115d..492f5bac 100644 --- a/lib/appwrite/models/dedicated_database_pitr_windows.rb +++ b/lib/appwrite/models/dedicated_database_pitr_windows.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "earliest" => "", "latest" => "" }.merge(map) DedicatedDatabasePITRWindows.new( earliest: map["earliest"], latest: map["latest"] diff --git a/lib/appwrite/models/dedicated_database_pooler.rb b/lib/appwrite/models/dedicated_database_pooler.rb index a87c1776..1804c09c 100644 --- a/lib/appwrite/models/dedicated_database_pooler.rb +++ b/lib/appwrite/models/dedicated_database_pooler.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => false, "mode" => "transaction", "maxConnections" => 100, "defaultPoolSize" => 20, "port" => 6432, "readWriteSplitting" => false, "poolerCpuRequest" => "", "poolerCpuLimit" => "", "poolerMemoryRequest" => "", "poolerMemoryLimit" => "" }.merge(map) DedicatedDatabasePooler.new( enabled: map["enabled"], mode: map["mode"], diff --git a/lib/appwrite/models/dedicated_database_replicas.rb b/lib/appwrite/models/dedicated_database_replicas.rb index 72106776..409c8b07 100644 --- a/lib/appwrite/models/dedicated_database_replicas.rb +++ b/lib/appwrite/models/dedicated_database_replicas.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "replicas" => 0, "syncMode" => "async", "syncDegraded" => false, "syncAcknowledgements" => 0, "syncStandbyCount" => 0, "members" => [] }.merge(map) DedicatedDatabaseReplicas.new( replicas: map["replicas"], sync_mode: map["syncMode"], diff --git a/lib/appwrite/models/dedicated_database_restoration.rb b/lib/appwrite/models/dedicated_database_restoration.rb index be6e9f26..a48bc0e7 100644 --- a/lib/appwrite/models/dedicated_database_restoration.rb +++ b/lib/appwrite/models/dedicated_database_restoration.rb @@ -10,6 +10,7 @@ class DedicatedDatabaseRestoration attr_reader :project_id attr_reader :backup_id attr_reader :type + attr_reader :restore_mode attr_reader :status attr_reader :target_time attr_reader :started_at @@ -24,6 +25,7 @@ def initialize( project_id:, backup_id:, type:, + restore_mode:, status:, target_time:, started_at:, @@ -37,6 +39,7 @@ def initialize( @project_id = project_id @backup_id = backup_id @type = type + @restore_mode = restore_mode @status = status @target_time = target_time @started_at = started_at @@ -45,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "databaseId" => "", "projectId" => "", "type" => "backup", "restoreMode" => "in_place", "status" => "pending", "error" => "" }.merge(map) DedicatedDatabaseRestoration.new( id: map["$id"], created_at: map["$createdAt"], @@ -53,6 +57,7 @@ def self.from(map:) project_id: map["projectId"], backup_id: map["backupId"], type: map["type"], + restore_mode: map["restoreMode"], status: map["status"], target_time: map["targetTime"], started_at: map["startedAt"], @@ -70,6 +75,7 @@ def to_map "projectId": @project_id, "backupId": @backup_id, "type": @type, + "restoreMode": @restore_mode, "status": @status, "targetTime": @target_time, "startedAt": @started_at, diff --git a/lib/appwrite/models/dedicated_database_restoration_list.rb b/lib/appwrite/models/dedicated_database_restoration_list.rb index dcb3f9ee..7755ec27 100644 --- a/lib/appwrite/models/dedicated_database_restoration_list.rb +++ b/lib/appwrite/models/dedicated_database_restoration_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "restorations" => [] }.merge(map) DedicatedDatabaseRestorationList.new( total: map["total"], restorations: map["restorations"].map { |it| DedicatedDatabaseRestoration.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_specification.rb b/lib/appwrite/models/dedicated_database_specification.rb index b5f26a33..2c0bc719 100644 --- a/lib/appwrite/models/dedicated_database_specification.rb +++ b/lib/appwrite/models/dedicated_database_specification.rb @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "slug" => "", "name" => "", "price" => 0, "storageOverageRate" => 0, "bandwidthOverageRate" => 0, "replicaRate" => 0, "pitrRate" => 0, "cpu" => 0, "memory" => 0, "maxConnections" => 0, "includedStorage" => 0, "includedBandwidth" => 0, "enabled" => false }.merge(map) DedicatedDatabaseSpecification.new( slug: map["slug"], name: map["name"], diff --git a/lib/appwrite/models/dedicated_database_specification_list.rb b/lib/appwrite/models/dedicated_database_specification_list.rb index 206eec28..e649aa18 100644 --- a/lib/appwrite/models/dedicated_database_specification_list.rb +++ b/lib/appwrite/models/dedicated_database_specification_list.rb @@ -5,31 +5,27 @@ module Models class DedicatedDatabaseSpecificationList attr_reader :specifications attr_reader :total - attr_reader :pricing def initialize( specifications:, - total:, - pricing: + total: ) @specifications = specifications @total = total - @pricing = pricing end def self.from(map:) + map = { "specifications" => [], "total" => 0 }.merge(map) DedicatedDatabaseSpecificationList.new( specifications: map["specifications"].map { |it| DedicatedDatabaseSpecification.from(map: it) }, - total: map["total"], - pricing: DedicatedDatabaseSpecificationPricing.from(map: map["pricing"]) + total: map["total"] ) end def to_map { "specifications": @specifications.map { |it| it.to_map }, - "total": @total, - "pricing": @pricing.to_map + "total": @total } end end diff --git a/lib/appwrite/models/dedicated_database_specification_pricing.rb b/lib/appwrite/models/dedicated_database_specification_pricing.rb deleted file mode 100644 index d6ef0ef8..00000000 --- a/lib/appwrite/models/dedicated_database_specification_pricing.rb +++ /dev/null @@ -1,42 +0,0 @@ -# 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 :pitr_rate - - def initialize( - storage_overage_rate:, - bandwidth_overage_rate:, - replica_rate:, - pitr_rate: - ) - @storage_overage_rate = storage_overage_rate - @bandwidth_overage_rate = bandwidth_overage_rate - @replica_rate = 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"], - pitr_rate: map["pitrRate"] - ) - end - - def to_map - { - "storageOverageRate": @storage_overage_rate, - "bandwidthOverageRate": @bandwidth_overage_rate, - "replicaRate": @replica_rate, - "pitrRate": @pitr_rate - } - end - end - end -end diff --git a/lib/appwrite/models/deployment.rb b/lib/appwrite/models/deployment.rb index 6fc3465b..c4749311 100644 --- a/lib/appwrite/models/deployment.rb +++ b/lib/appwrite/models/deployment.rb @@ -90,6 +90,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "type" => "", "resourceId" => "", "resourceType" => "", "entrypoint" => "", "sourceSize" => 0, "buildSize" => 0, "totalSize" => 0, "buildId" => "", "activate" => false, "screenshotLight" => "", "screenshotDark" => "", "buildLogs" => "", "buildDuration" => 0, "providerRepositoryName" => "", "providerRepositoryOwner" => "", "providerRepositoryUrl" => "", "providerCommitHash" => "", "providerCommitAuthorUrl" => "", "providerCommitAuthor" => "", "providerCommitMessage" => "", "providerCommitUrl" => "", "providerBranch" => "", "providerBranchUrl" => "" }.merge(map) Deployment.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/deployment_list.rb b/lib/appwrite/models/deployment_list.rb index f9a2d696..5ff996f5 100644 --- a/lib/appwrite/models/deployment_list.rb +++ b/lib/appwrite/models/deployment_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "deployments" => [] }.merge(map) DeploymentList.new( total: map["total"], deployments: map["deployments"].map { |it| Deployment.from(map: it) } diff --git a/lib/appwrite/models/dev_key.rb b/lib/appwrite/models/dev_key.rb deleted file mode 100644 index 4389e82a..00000000 --- a/lib/appwrite/models/dev_key.rb +++ /dev/null @@ -1,62 +0,0 @@ -# frozen_string_literal: true - -module Appwrite - module Models - class DevKey - attr_reader :id - attr_reader :created_at - attr_reader :updated_at - attr_reader :name - attr_reader :expire - attr_reader :secret - attr_reader :accessed_at - attr_reader :sdks - - def initialize( - id:, - created_at:, - updated_at:, - name:, - expire:, - secret:, - accessed_at:, - sdks: - ) - @id = id - @created_at = created_at - @updated_at = updated_at - @name = name - @expire = expire - @secret = secret - @accessed_at = accessed_at - @sdks = sdks - end - - def self.from(map:) - DevKey.new( - id: map["$id"], - created_at: map["$createdAt"], - updated_at: map["$updatedAt"], - name: map["name"], - expire: map["expire"], - secret: map["secret"], - accessed_at: map["accessedAt"], - sdks: map["sdks"] - ) - end - - def to_map - { - "$id": @id, - "$createdAt": @created_at, - "$updatedAt": @updated_at, - "name": @name, - "expire": @expire, - "secret": @secret, - "accessedAt": @accessed_at, - "sdks": @sdks - } - end - end - end -end diff --git a/lib/appwrite/models/document.rb b/lib/appwrite/models/document.rb index 0cc8a466..02ed60e3 100644 --- a/lib/appwrite/models/document.rb +++ b/lib/appwrite/models/document.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$sequence" => "", "$collectionId" => "", "$databaseId" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [] }.merge(map) Document.new( id: map["$id"], sequence: map["$sequence"], diff --git a/lib/appwrite/models/document_list.rb b/lib/appwrite/models/document_list.rb index 254e19e2..9a1c4f69 100644 --- a/lib/appwrite/models/document_list.rb +++ b/lib/appwrite/models/document_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "documents" => [] }.merge(map) DocumentList.new( total: map["total"], documents: map["documents"].map { |it| Document.from(map: it) } diff --git a/lib/appwrite/models/email_template.rb b/lib/appwrite/models/email_template.rb index 5cacd768..ee13cfb6 100644 --- a/lib/appwrite/models/email_template.rb +++ b/lib/appwrite/models/email_template.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "templateId" => "", "locale" => "", "message" => "", "senderName" => "", "senderEmail" => "", "replyToEmail" => "", "replyToName" => "", "subject" => "" }.merge(map) EmailTemplate.new( template_id: map["templateId"], locale: map["locale"], diff --git a/lib/appwrite/models/email_template_list.rb b/lib/appwrite/models/email_template_list.rb index fbc649f1..4334c55c 100644 --- a/lib/appwrite/models/email_template_list.rb +++ b/lib/appwrite/models/email_template_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "templates" => [] }.merge(map) EmailTemplateList.new( total: map["total"], templates: map["templates"].map { |it| EmailTemplate.from(map: it) } diff --git a/lib/appwrite/models/embedding.rb b/lib/appwrite/models/embedding.rb index 177a94f4..f7c9978d 100644 --- a/lib/appwrite/models/embedding.rb +++ b/lib/appwrite/models/embedding.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "model" => "", "dimension" => 0, "embedding" => [], "error" => "" }.merge(map) Embedding.new( model: map["model"], dimension: map["dimension"], diff --git a/lib/appwrite/models/embedding_list.rb b/lib/appwrite/models/embedding_list.rb index 848b50d4..10090e93 100644 --- a/lib/appwrite/models/embedding_list.rb +++ b/lib/appwrite/models/embedding_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "embeddings" => [] }.merge(map) EmbeddingList.new( total: map["total"], embeddings: map["embeddings"].map { |it| Embedding.from(map: it) } diff --git a/lib/appwrite/models/ephemeral_key.rb b/lib/appwrite/models/ephemeral_key.rb index 14761c4f..cdc9eb77 100644 --- a/lib/appwrite/models/ephemeral_key.rb +++ b/lib/appwrite/models/ephemeral_key.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "expire" => "", "scopes" => [], "secret" => "", "accessedAt" => "", "sdks" => [] }.merge(map) EphemeralKey.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/execution.rb b/lib/appwrite/models/execution.rb index 55a701d5..53f66332 100644 --- a/lib/appwrite/models/execution.rb +++ b/lib/appwrite/models/execution.rb @@ -66,6 +66,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "resourceId" => "", "resourceType" => "functions", "deploymentId" => "", "requestMethod" => "", "requestPath" => "", "requestHeaders" => [], "responseStatusCode" => 0, "responseBody" => "", "responseHeaders" => [], "logs" => "", "errors" => "", "duration" => 0 }.merge(map) Execution.new( id: map["$id"], created_at: map["$createdAt"], @@ -133,6 +134,7 @@ def validate_trigger(trigger) Appwrite::Enums::ExecutionTrigger::HTTP, Appwrite::Enums::ExecutionTrigger::SCHEDULE, Appwrite::Enums::ExecutionTrigger::EVENT, + Appwrite::Enums::ExecutionTrigger::EMAIL, ] unless valid_trigger.include?(trigger) diff --git a/lib/appwrite/models/execution_list.rb b/lib/appwrite/models/execution_list.rb index 531551db..457400c3 100644 --- a/lib/appwrite/models/execution_list.rb +++ b/lib/appwrite/models/execution_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "executions" => [] }.merge(map) ExecutionList.new( total: map["total"], executions: map["executions"].map { |it| Execution.from(map: it) } diff --git a/lib/appwrite/models/file.rb b/lib/appwrite/models/file.rb index 66ee936b..d448ece2 100644 --- a/lib/appwrite/models/file.rb +++ b/lib/appwrite/models/file.rb @@ -57,6 +57,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "bucketId" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "name" => "", "folder" => "", "key" => "", "signature" => "", "mimeType" => "", "sizeOriginal" => 0, "sizeActual" => 0, "chunksTotal" => 0, "chunksUploaded" => 0, "encryption" => false, "compression" => "none" }.merge(map) File.new( id: map["$id"], bucket_id: map["bucketId"], diff --git a/lib/appwrite/models/file_list.rb b/lib/appwrite/models/file_list.rb index 7a033d5a..9aee37f8 100644 --- a/lib/appwrite/models/file_list.rb +++ b/lib/appwrite/models/file_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "files" => [] }.merge(map) FileList.new( total: map["total"], files: map["files"].map { |it| File.from(map: it) } diff --git a/lib/appwrite/models/framework.rb b/lib/appwrite/models/framework.rb index 98108bfe..4dcc1d52 100644 --- a/lib/appwrite/models/framework.rb +++ b/lib/appwrite/models/framework.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "name" => "", "buildRuntime" => "", "runtimes" => [], "adapters" => [] }.merge(map) Framework.new( key: map["key"], name: map["name"], diff --git a/lib/appwrite/models/framework_adapter.rb b/lib/appwrite/models/framework_adapter.rb index 81d06e20..7a35dce5 100644 --- a/lib/appwrite/models/framework_adapter.rb +++ b/lib/appwrite/models/framework_adapter.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "installCommand" => "", "buildCommand" => "", "outputDirectory" => "" }.merge(map) FrameworkAdapter.new( key: map["key"], install_command: map["installCommand"], diff --git a/lib/appwrite/models/framework_list.rb b/lib/appwrite/models/framework_list.rb index da86b56d..7f477fe7 100644 --- a/lib/appwrite/models/framework_list.rb +++ b/lib/appwrite/models/framework_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "frameworks" => [] }.merge(map) FrameworkList.new( total: map["total"], frameworks: map["frameworks"].map { |it| Framework.from(map: it) } diff --git a/lib/appwrite/models/function.rb b/lib/appwrite/models/function.rb index 6d8b38b7..4c5fa06f 100644 --- a/lib/appwrite/models/function.rb +++ b/lib/appwrite/models/function.rb @@ -36,6 +36,7 @@ class Function attr_reader :provider_paths attr_reader :build_specification attr_reader :runtime_specification + attr_reader :email_enabled def initialize( id:, @@ -57,7 +58,7 @@ def initialize( vars:, events:, schedule:, - interval:, + interval: 0, timeout:, entrypoint:, commands:, @@ -70,7 +71,8 @@ def initialize( provider_branches:, provider_paths:, build_specification:, - runtime_specification: + runtime_specification:, + email_enabled: ) @id = id @created_at = created_at @@ -105,9 +107,11 @@ def initialize( @provider_paths = provider_paths @build_specification = build_specification @runtime_specification = runtime_specification + @email_enabled = email_enabled end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "execute" => [], "name" => "", "enabled" => true, "live" => true, "logging" => true, "runtime" => "", "deploymentRetention" => 0, "deploymentId" => "", "deploymentCreatedAt" => "", "latestDeploymentId" => "", "latestDeploymentCreatedAt" => "", "latestDeploymentStatus" => "", "scopes" => [], "vars" => [], "events" => [], "schedule" => "", "timeout" => 15, "entrypoint" => "", "commands" => "", "version" => "v5", "installationId" => "", "providerRepositoryId" => "", "providerBranch" => "", "providerRootDirectory" => "", "providerSilentMode" => false, "providerBranches" => [], "providerPaths" => [], "buildSpecification" => "s-1vcpu-512mb", "runtimeSpecification" => "s-1vcpu-512mb" }.merge(map) Function.new( id: map["$id"], created_at: map["$createdAt"], @@ -141,7 +145,8 @@ def self.from(map:) provider_branches: map["providerBranches"], provider_paths: map["providerPaths"], build_specification: map["buildSpecification"], - runtime_specification: map["runtimeSpecification"] + runtime_specification: map["runtimeSpecification"], + email_enabled: map["emailEnabled"] ) end @@ -179,7 +184,8 @@ def to_map "providerBranches": @provider_branches, "providerPaths": @provider_paths, "buildSpecification": @build_specification, - "runtimeSpecification": @runtime_specification + "runtimeSpecification": @runtime_specification, + "emailEnabled": @email_enabled } end end diff --git a/lib/appwrite/models/function_list.rb b/lib/appwrite/models/function_list.rb index 8ac71cf1..554fdeb2 100644 --- a/lib/appwrite/models/function_list.rb +++ b/lib/appwrite/models/function_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "functions" => [] }.merge(map) FunctionList.new( total: map["total"], functions: map["functions"].map { |it| Function.from(map: it) } diff --git a/lib/appwrite/models/headers.rb b/lib/appwrite/models/headers.rb index 5c43bea8..270773e3 100644 --- a/lib/appwrite/models/headers.rb +++ b/lib/appwrite/models/headers.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "value" => "" }.merge(map) Headers.new( name: map["name"], value: map["value"] diff --git a/lib/appwrite/models/identity.rb b/lib/appwrite/models/identity.rb index abf586a2..4261f302 100644 --- a/lib/appwrite/models/identity.rb +++ b/lib/appwrite/models/identity.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "provider" => "", "providerUid" => "", "providerEmail" => "", "providerAccessToken" => "", "providerAccessTokenExpiry" => "", "providerRefreshToken" => "", "providerIdToken" => "" }.merge(map) Identity.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/identity_list.rb b/lib/appwrite/models/identity_list.rb index bef444be..18d48d2f 100644 --- a/lib/appwrite/models/identity_list.rb +++ b/lib/appwrite/models/identity_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "identities" => [] }.merge(map) IdentityList.new( total: map["total"], identities: map["identities"].map { |it| Identity.from(map: it) } diff --git a/lib/appwrite/models/index.rb b/lib/appwrite/models/index.rb index 20b6e62b..da063ec1 100644 --- a/lib/appwrite/models/index.rb +++ b/lib/appwrite/models/index.rb @@ -24,7 +24,7 @@ def initialize( error:, attributes:, lengths:, - orders: + orders: [] ) @id = id @created_at = created_at @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "key" => "", "type" => "", "error" => "", "attributes" => [], "lengths" => [] }.merge(map) Index.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/index_list.rb b/lib/appwrite/models/index_list.rb index a0795d16..a096b0c2 100644 --- a/lib/appwrite/models/index_list.rb +++ b/lib/appwrite/models/index_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "indexes" => [] }.merge(map) IndexList.new( total: map["total"], indexes: map["indexes"].map { |it| Index.from(map: it) } diff --git a/lib/appwrite/models/insight.rb b/lib/appwrite/models/insight.rb index a10df160..f2ede1a1 100644 --- a/lib/appwrite/models/insight.rb +++ b/lib/appwrite/models/insight.rb @@ -60,6 +60,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "reportId" => "", "type" => "", "severity" => "info", "status" => "active", "resourceType" => "", "resourceId" => "", "parentResourceType" => "", "parentResourceId" => "", "title" => "", "summary" => "", "ctas" => [] }.merge(map) Insight.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/insight_cta.rb b/lib/appwrite/models/insight_cta.rb index 36670cbe..1a92a732 100644 --- a/lib/appwrite/models/insight_cta.rb +++ b/lib/appwrite/models/insight_cta.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "label" => "", "service" => "", "method" => "", "params" => {} }.merge(map) InsightCTA.new( label: map["label"], service: map["service"], diff --git a/lib/appwrite/models/insight_list.rb b/lib/appwrite/models/insight_list.rb index af19aa84..70a1285b 100644 --- a/lib/appwrite/models/insight_list.rb +++ b/lib/appwrite/models/insight_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "insights" => [] }.merge(map) InsightList.new( total: map["total"], insights: map["insights"].map { |it| Insight.from(map: it) } diff --git a/lib/appwrite/models/jwt.rb b/lib/appwrite/models/jwt.rb index 73d8c92c..af1e7eb8 100644 --- a/lib/appwrite/models/jwt.rb +++ b/lib/appwrite/models/jwt.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "jwt" => "" }.merge(map) Jwt.new( jwt: map["jwt"] ) diff --git a/lib/appwrite/models/key.rb b/lib/appwrite/models/key.rb index 4df47cf3..5eb79318 100644 --- a/lib/appwrite/models/key.rb +++ b/lib/appwrite/models/key.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "expire" => "", "scopes" => [], "secret" => "", "accessedAt" => "", "sdks" => [] }.merge(map) Key.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/key_list.rb b/lib/appwrite/models/key_list.rb index d7a9649f..ac413cff 100644 --- a/lib/appwrite/models/key_list.rb +++ b/lib/appwrite/models/key_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "keys" => [] }.merge(map) KeyList.new( total: map["total"], keys: map["keys"].map { |it| Key.from(map: it) } diff --git a/lib/appwrite/models/language.rb b/lib/appwrite/models/language.rb index 8850a69b..b2acb8d8 100644 --- a/lib/appwrite/models/language.rb +++ b/lib/appwrite/models/language.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "code" => "", "nativeName" => "" }.merge(map) Language.new( name: map["name"], code: map["code"], diff --git a/lib/appwrite/models/language_list.rb b/lib/appwrite/models/language_list.rb index 118fc410..ec55d81e 100644 --- a/lib/appwrite/models/language_list.rb +++ b/lib/appwrite/models/language_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "languages" => [] }.merge(map) LanguageList.new( total: map["total"], languages: map["languages"].map { |it| Language.from(map: it) } diff --git a/lib/appwrite/models/locale.rb b/lib/appwrite/models/locale.rb index a31aea64..1fcb8607 100644 --- a/lib/appwrite/models/locale.rb +++ b/lib/appwrite/models/locale.rb @@ -63,6 +63,7 @@ def initialize( end def self.from(map:) + map = { "ip" => "", "countryCode" => "", "country" => "", "continentCode" => "", "continent" => "", "eu" => false, "currency" => "" }.merge(map) Locale.new( ip: map["ip"], country_code: map["countryCode"], diff --git a/lib/appwrite/models/locale_code.rb b/lib/appwrite/models/locale_code.rb index 6089272b..4795135c 100644 --- a/lib/appwrite/models/locale_code.rb +++ b/lib/appwrite/models/locale_code.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "code" => "", "name" => "" }.merge(map) LocaleCode.new( code: map["code"], name: map["name"] diff --git a/lib/appwrite/models/locale_code_list.rb b/lib/appwrite/models/locale_code_list.rb index b93213cb..e771b6d7 100644 --- a/lib/appwrite/models/locale_code_list.rb +++ b/lib/appwrite/models/locale_code_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "localeCodes" => [] }.merge(map) LocaleCodeList.new( total: map["total"], locale_codes: map["localeCodes"].map { |it| LocaleCode.from(map: it) } diff --git a/lib/appwrite/models/log.rb b/lib/appwrite/models/log.rb deleted file mode 100644 index 89e1a676..00000000 --- a/lib/appwrite/models/log.rb +++ /dev/null @@ -1,132 +0,0 @@ -# frozen_string_literal: true - -module Appwrite - module Models - class Log - attr_reader :event - attr_reader :user_id - attr_reader :user_email - attr_reader :user_name - attr_reader :mode - attr_reader :user_type - attr_reader :ip - attr_reader :time - attr_reader :os_code - attr_reader :os_name - attr_reader :os_version - attr_reader :client_type - attr_reader :client_code - attr_reader :client_name - attr_reader :client_version - attr_reader :client_engine - attr_reader :client_engine_version - attr_reader :device_name - attr_reader :device_brand - attr_reader :device_model - attr_reader :country_code - attr_reader :country_name - - def initialize( - event:, - user_id:, - user_email:, - user_name:, - mode:, - user_type:, - ip:, - time:, - os_code:, - os_name:, - os_version:, - client_type:, - client_code:, - client_name:, - client_version:, - client_engine:, - client_engine_version:, - device_name:, - device_brand:, - device_model:, - country_code:, - country_name: - ) - @event = event - @user_id = user_id - @user_email = user_email - @user_name = user_name - @mode = mode - @user_type = user_type - @ip = ip - @time = time - @os_code = os_code - @os_name = os_name - @os_version = os_version - @client_type = client_type - @client_code = client_code - @client_name = client_name - @client_version = client_version - @client_engine = client_engine - @client_engine_version = client_engine_version - @device_name = device_name - @device_brand = device_brand - @device_model = device_model - @country_code = country_code - @country_name = country_name - end - - def self.from(map:) - Log.new( - event: map["event"], - user_id: map["userId"], - user_email: map["userEmail"], - user_name: map["userName"], - mode: map["mode"], - user_type: map["userType"], - ip: map["ip"], - time: map["time"], - os_code: map["osCode"], - os_name: map["osName"], - os_version: map["osVersion"], - client_type: map["clientType"], - client_code: map["clientCode"], - client_name: map["clientName"], - client_version: map["clientVersion"], - client_engine: map["clientEngine"], - client_engine_version: map["clientEngineVersion"], - device_name: map["deviceName"], - device_brand: map["deviceBrand"], - device_model: map["deviceModel"], - country_code: map["countryCode"], - country_name: map["countryName"] - ) - end - - def to_map - { - "event": @event, - "userId": @user_id, - "userEmail": @user_email, - "userName": @user_name, - "mode": @mode, - "userType": @user_type, - "ip": @ip, - "time": @time, - "osCode": @os_code, - "osName": @os_name, - "osVersion": @os_version, - "clientType": @client_type, - "clientCode": @client_code, - "clientName": @client_name, - "clientVersion": @client_version, - "clientEngine": @client_engine, - "clientEngineVersion": @client_engine_version, - "deviceName": @device_name, - "deviceBrand": @device_brand, - "deviceModel": @device_model, - "countryCode": @country_code, - "countryName": @country_name - } - end - end - end -end diff --git a/lib/appwrite/models/log_list.rb b/lib/appwrite/models/log_list.rb deleted file mode 100644 index cdad965e..00000000 --- a/lib/appwrite/models/log_list.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -module Appwrite - module Models - class LogList - attr_reader :total - attr_reader :logs - - def initialize( - total:, - logs: - ) - @total = total - @logs = logs - end - - def self.from(map:) - LogList.new( - total: map["total"], - logs: map["logs"].map { |it| Log.from(map: it) } - ) - end - - def to_map - { - "total": @total, - "logs": @logs.map { |it| it.to_map } - } - end - end - end -end diff --git a/lib/appwrite/models/membership.rb b/lib/appwrite/models/membership.rb index 84b3ce1f..61e20c1d 100644 --- a/lib/appwrite/models/membership.rb +++ b/lib/appwrite/models/membership.rb @@ -54,6 +54,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "userName" => "", "userEmail" => "", "userPhone" => "", "teamId" => "", "teamName" => "", "invited" => "", "joined" => "", "confirm" => false, "mfa" => false, "userAccessedAt" => "", "roles" => [] }.merge(map) Membership.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/membership_list.rb b/lib/appwrite/models/membership_list.rb index 0cc220c0..dceb8db0 100644 --- a/lib/appwrite/models/membership_list.rb +++ b/lib/appwrite/models/membership_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "memberships" => [] }.merge(map) MembershipList.new( total: map["total"], memberships: map["memberships"].map { |it| Membership.from(map: it) } diff --git a/lib/appwrite/models/message.rb b/lib/appwrite/models/message.rb index 456afe3a..49b032df 100644 --- a/lib/appwrite/models/message.rb +++ b/lib/appwrite/models/message.rb @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "providerType" => "", "topics" => [], "users" => [], "targets" => [], "deliveredTotal" => 0, "data" => {}, "status" => "draft" }.merge(map) Message.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/message_list.rb b/lib/appwrite/models/message_list.rb index 50175444..d3930021 100644 --- a/lib/appwrite/models/message_list.rb +++ b/lib/appwrite/models/message_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "messages" => [] }.merge(map) MessageList.new( total: map["total"], messages: map["messages"].map { |it| Message.from(map: it) } diff --git a/lib/appwrite/models/mfa_challenge.rb b/lib/appwrite/models/mfa_challenge.rb index 6ba21fef..384f9031 100644 --- a/lib/appwrite/models/mfa_challenge.rb +++ b/lib/appwrite/models/mfa_challenge.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "expire" => "" }.merge(map) MfaChallenge.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/mfa_challenge_secret.rb b/lib/appwrite/models/mfa_challenge_secret.rb index ad8abbcd..36cb2e7d 100644 --- a/lib/appwrite/models/mfa_challenge_secret.rb +++ b/lib/appwrite/models/mfa_challenge_secret.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "expire" => "", "code" => "" }.merge(map) MfaChallengeSecret.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/mfa_factors.rb b/lib/appwrite/models/mfa_factors.rb index 55b58ca2..55db99ea 100644 --- a/lib/appwrite/models/mfa_factors.rb +++ b/lib/appwrite/models/mfa_factors.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "totp" => false, "phone" => false, "email" => false, "recoveryCode" => false, "custom" => false }.merge(map) MfaFactors.new( totp: map["totp"], phone: map["phone"], diff --git a/lib/appwrite/models/mfa_recovery_codes.rb b/lib/appwrite/models/mfa_recovery_codes.rb index 1fd53c11..c9097acb 100644 --- a/lib/appwrite/models/mfa_recovery_codes.rb +++ b/lib/appwrite/models/mfa_recovery_codes.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "recoveryCodes" => [] }.merge(map) MfaRecoveryCodes.new( recovery_codes: map["recoveryCodes"] ) diff --git a/lib/appwrite/models/mfa_type.rb b/lib/appwrite/models/mfa_type.rb index 0612dc2d..4a8c7482 100644 --- a/lib/appwrite/models/mfa_type.rb +++ b/lib/appwrite/models/mfa_type.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "secret" => "", "uri" => "" }.merge(map) MfaType.new( secret: map["secret"], uri: map["uri"] diff --git a/lib/appwrite/models/mock_number.rb b/lib/appwrite/models/mock_number.rb index 59d96f27..8bb41c9b 100644 --- a/lib/appwrite/models/mock_number.rb +++ b/lib/appwrite/models/mock_number.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "number" => "", "otp" => "", "$createdAt" => "", "$updatedAt" => "" }.merge(map) MockNumber.new( number: map["number"], otp: map["otp"], diff --git a/lib/appwrite/models/mock_number_list.rb b/lib/appwrite/models/mock_number_list.rb index 56a7fdd2..ca3a9af1 100644 --- a/lib/appwrite/models/mock_number_list.rb +++ b/lib/appwrite/models/mock_number_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "mockNumbers" => [] }.merge(map) MockNumberList.new( total: map["total"], mock_numbers: map["mockNumbers"].map { |it| MockNumber.from(map: it) } diff --git a/lib/appwrite/models/o_auth2_amazon.rb b/lib/appwrite/models/o_auth2_amazon.rb index 177ce121..1afa9f98 100644 --- a/lib/appwrite/models/o_auth2_amazon.rb +++ b/lib/appwrite/models/o_auth2_amazon.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Amazon.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_apple.rb b/lib/appwrite/models/o_auth2_apple.rb index f5949d06..ed1b5058 100644 --- a/lib/appwrite/models/o_auth2_apple.rb +++ b/lib/appwrite/models/o_auth2_apple.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "serviceId" => "", "keyId" => "", "teamId" => "", "p8File" => "", "nativeEnabled" => false, "nativeClientIds" => [] }.merge(map) OAuth2Apple.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_appwrite.rb b/lib/appwrite/models/o_auth2_appwrite.rb index c12a6b55..e9624285 100644 --- a/lib/appwrite/models/o_auth2_appwrite.rb +++ b/lib/appwrite/models/o_auth2_appwrite.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Appwrite.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_auth0.rb b/lib/appwrite/models/o_auth2_auth0.rb index e9cf3cb0..0625fe06 100644 --- a/lib/appwrite/models/o_auth2_auth0.rb +++ b/lib/appwrite/models/o_auth2_auth0.rb @@ -22,11 +22,12 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) @endpoint = endpoint end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [], "endpoint" => "" }.merge(map) OAuth2Auth0.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_authentik.rb b/lib/appwrite/models/o_auth2_authentik.rb index 81fc7ff8..643597f5 100644 --- a/lib/appwrite/models/o_auth2_authentik.rb +++ b/lib/appwrite/models/o_auth2_authentik.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "endpoint" => "" }.merge(map) OAuth2Authentik.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_autodesk.rb b/lib/appwrite/models/o_auth2_autodesk.rb index f260b12e..fa2a8d98 100644 --- a/lib/appwrite/models/o_auth2_autodesk.rb +++ b/lib/appwrite/models/o_auth2_autodesk.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Autodesk.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_bitbucket.rb b/lib/appwrite/models/o_auth2_bitbucket.rb index 44509504..f4686ebc 100644 --- a/lib/appwrite/models/o_auth2_bitbucket.rb +++ b/lib/appwrite/models/o_auth2_bitbucket.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "key" => "", "secret" => "" }.merge(map) OAuth2Bitbucket.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_bitly.rb b/lib/appwrite/models/o_auth2_bitly.rb index ad116ed0..a9efb469 100644 --- a/lib/appwrite/models/o_auth2_bitly.rb +++ b/lib/appwrite/models/o_auth2_bitly.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Bitly.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_box.rb b/lib/appwrite/models/o_auth2_box.rb index 7cdfedd0..e2aa2269 100644 --- a/lib/appwrite/models/o_auth2_box.rb +++ b/lib/appwrite/models/o_auth2_box.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Box.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_cloudflare.rb b/lib/appwrite/models/o_auth2_cloudflare.rb index 7f3e65bf..f0bc5549 100644 --- a/lib/appwrite/models/o_auth2_cloudflare.rb +++ b/lib/appwrite/models/o_auth2_cloudflare.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Cloudflare.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_dailymotion.rb b/lib/appwrite/models/o_auth2_dailymotion.rb index 31e10ed1..241d92c7 100644 --- a/lib/appwrite/models/o_auth2_dailymotion.rb +++ b/lib/appwrite/models/o_auth2_dailymotion.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "apiKey" => "", "apiSecret" => "" }.merge(map) OAuth2Dailymotion.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_discord.rb b/lib/appwrite/models/o_auth2_discord.rb index 5d7db0cb..972672bd 100644 --- a/lib/appwrite/models/o_auth2_discord.rb +++ b/lib/appwrite/models/o_auth2_discord.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [] }.merge(map) OAuth2Discord.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_disqus.rb b/lib/appwrite/models/o_auth2_disqus.rb index 2b8e4261..e1670515 100644 --- a/lib/appwrite/models/o_auth2_disqus.rb +++ b/lib/appwrite/models/o_auth2_disqus.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "publicKey" => "", "secretKey" => "" }.merge(map) OAuth2Disqus.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_dropbox.rb b/lib/appwrite/models/o_auth2_dropbox.rb index d5581312..d57c294d 100644 --- a/lib/appwrite/models/o_auth2_dropbox.rb +++ b/lib/appwrite/models/o_auth2_dropbox.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "appKey" => "", "appSecret" => "" }.merge(map) OAuth2Dropbox.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_etsy.rb b/lib/appwrite/models/o_auth2_etsy.rb index 87acab75..2af4595a 100644 --- a/lib/appwrite/models/o_auth2_etsy.rb +++ b/lib/appwrite/models/o_auth2_etsy.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "keyString" => "", "sharedSecret" => "" }.merge(map) OAuth2Etsy.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_facebook.rb b/lib/appwrite/models/o_auth2_facebook.rb index f42ab1e7..6a6206de 100644 --- a/lib/appwrite/models/o_auth2_facebook.rb +++ b/lib/appwrite/models/o_auth2_facebook.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "appId" => "", "appSecret" => "" }.merge(map) OAuth2Facebook.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_figma.rb b/lib/appwrite/models/o_auth2_figma.rb index 7da8c796..2470388c 100644 --- a/lib/appwrite/models/o_auth2_figma.rb +++ b/lib/appwrite/models/o_auth2_figma.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Figma.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_fusion_auth.rb b/lib/appwrite/models/o_auth2_fusion_auth.rb index 74e205e3..28bf8307 100644 --- a/lib/appwrite/models/o_auth2_fusion_auth.rb +++ b/lib/appwrite/models/o_auth2_fusion_auth.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "endpoint" => "" }.merge(map) OAuth2FusionAuth.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_github.rb b/lib/appwrite/models/o_auth2_github.rb index d46e1e38..66986a27 100644 --- a/lib/appwrite/models/o_auth2_github.rb +++ b/lib/appwrite/models/o_auth2_github.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [] }.merge(map) OAuth2Github.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_gitlab.rb b/lib/appwrite/models/o_auth2_gitlab.rb index 2f1d2237..5a7b7f5b 100644 --- a/lib/appwrite/models/o_auth2_gitlab.rb +++ b/lib/appwrite/models/o_auth2_gitlab.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "applicationId" => "", "secret" => "", "endpoint" => "" }.merge(map) OAuth2Gitlab.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_google.rb b/lib/appwrite/models/o_auth2_google.rb index b646c30d..be1959fd 100644 --- a/lib/appwrite/models/o_auth2_google.rb +++ b/lib/appwrite/models/o_auth2_google.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => ["consent"], "nativeEnabled" => false, "nativeClientIds" => [] }.merge(map) OAuth2Google.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_hugging_face.rb b/lib/appwrite/models/o_auth2_hugging_face.rb index c75e13cc..43430cb0 100644 --- a/lib/appwrite/models/o_auth2_hugging_face.rb +++ b/lib/appwrite/models/o_auth2_hugging_face.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2HuggingFace.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_keycloak.rb b/lib/appwrite/models/o_auth2_keycloak.rb index 6af51b90..3e432d14 100644 --- a/lib/appwrite/models/o_auth2_keycloak.rb +++ b/lib/appwrite/models/o_auth2_keycloak.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "endpoint" => "", "realmName" => "" }.merge(map) OAuth2Keycloak.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_kick.rb b/lib/appwrite/models/o_auth2_kick.rb index eb5c8092..1d764fa3 100644 --- a/lib/appwrite/models/o_auth2_kick.rb +++ b/lib/appwrite/models/o_auth2_kick.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Kick.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_linkedin.rb b/lib/appwrite/models/o_auth2_linkedin.rb index 8b91b062..bcac2a97 100644 --- a/lib/appwrite/models/o_auth2_linkedin.rb +++ b/lib/appwrite/models/o_auth2_linkedin.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "primaryClientSecret" => "" }.merge(map) OAuth2Linkedin.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_microsoft.rb b/lib/appwrite/models/o_auth2_microsoft.rb index 29c2cb1e..4525c54c 100644 --- a/lib/appwrite/models/o_auth2_microsoft.rb +++ b/lib/appwrite/models/o_auth2_microsoft.rb @@ -22,11 +22,12 @@ def initialize( @enabled = enabled @application_id = application_id @application_secret = application_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) @tenant = tenant end def self.from(map:) + map = { "$id" => "", "enabled" => false, "applicationId" => "", "applicationSecret" => "", "prompt" => [], "tenant" => "" }.merge(map) OAuth2Microsoft.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_notion.rb b/lib/appwrite/models/o_auth2_notion.rb index 3382c410..1869df5b 100644 --- a/lib/appwrite/models/o_auth2_notion.rb +++ b/lib/appwrite/models/o_auth2_notion.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "oauthClientId" => "", "oauthClientSecret" => "" }.merge(map) OAuth2Notion.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_oidc.rb b/lib/appwrite/models/o_auth2_oidc.rb index a034231b..a3cbee0e 100644 --- a/lib/appwrite/models/o_auth2_oidc.rb +++ b/lib/appwrite/models/o_auth2_oidc.rb @@ -7,11 +7,11 @@ class OAuth2Oidc attr_reader :enabled attr_reader :client_id attr_reader :client_secret + attr_reader :prompt attr_reader :well_known_url attr_reader :authorization_url attr_reader :token_url attr_reader :user_info_url - attr_reader :prompt attr_reader :max_age def initialize( @@ -19,36 +19,37 @@ def initialize( enabled:, client_id:, client_secret:, + prompt:, well_known_url:, authorization_url:, token_url:, user_info_url:, - prompt:, max_age: ) @id = id @enabled = enabled @client_id = client_id @client_secret = client_secret + @prompt = validate_prompt(prompt) @well_known_url = well_known_url @authorization_url = authorization_url @token_url = token_url @user_info_url = user_info_url - @prompt = validate_prompt(prompt) @max_age = max_age end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [], "wellKnownURL" => "", "authorizationURL" => "", "tokenURL" => "", "userInfoURL" => "" }.merge(map) OAuth2Oidc.new( id: map["$id"], enabled: map["enabled"], client_id: map["clientId"], client_secret: map["clientSecret"], + prompt: map["prompt"], well_known_url: map["wellKnownURL"], authorization_url: map["authorizationURL"], token_url: map["tokenURL"], user_info_url: map["userInfoURL"], - prompt: map["prompt"], max_age: map["maxAge"] ) end @@ -59,11 +60,11 @@ def to_map "enabled": @enabled, "clientId": @client_id, "clientSecret": @client_secret, + "prompt": @prompt, "wellKnownURL": @well_known_url, "authorizationURL": @authorization_url, "tokenURL": @token_url, "userInfoURL": @user_info_url, - "prompt": @prompt, "maxAge": @max_age } end diff --git a/lib/appwrite/models/o_auth2_okta.rb b/lib/appwrite/models/o_auth2_okta.rb index 11d5746f..4abfdd09 100644 --- a/lib/appwrite/models/o_auth2_okta.rb +++ b/lib/appwrite/models/o_auth2_okta.rb @@ -24,12 +24,13 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) @domain = domain @authorization_server_id = authorization_server_id end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [], "domain" => "", "authorizationServerId" => "" }.merge(map) OAuth2Okta.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_paypal.rb b/lib/appwrite/models/o_auth2_paypal.rb index 32263b46..27db8cdd 100644 --- a/lib/appwrite/models/o_auth2_paypal.rb +++ b/lib/appwrite/models/o_auth2_paypal.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "secretKey" => "" }.merge(map) OAuth2Paypal.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_podio.rb b/lib/appwrite/models/o_auth2_podio.rb index d1efea82..f25f60e2 100644 --- a/lib/appwrite/models/o_auth2_podio.rb +++ b/lib/appwrite/models/o_auth2_podio.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Podio.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_provider_list.rb b/lib/appwrite/models/o_auth2_provider_list.rb index 16bdbbaf..40596466 100644 --- a/lib/appwrite/models/o_auth2_provider_list.rb +++ b/lib/appwrite/models/o_auth2_provider_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "providers" => [] }.merge(map) OAuth2ProviderList.new( total: map["total"], providers: map["providers"] diff --git a/lib/appwrite/models/o_auth2_resend.rb b/lib/appwrite/models/o_auth2_resend.rb index 9a64087d..86084bde 100644 --- a/lib/appwrite/models/o_auth2_resend.rb +++ b/lib/appwrite/models/o_auth2_resend.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Resend.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_salesforce.rb b/lib/appwrite/models/o_auth2_salesforce.rb index 0cd7bc78..0a3ae31a 100644 --- a/lib/appwrite/models/o_auth2_salesforce.rb +++ b/lib/appwrite/models/o_auth2_salesforce.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @customer_key = customer_key @customer_secret = customer_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "customerKey" => "", "customerSecret" => "", "prompt" => [] }.merge(map) OAuth2Salesforce.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_slack.rb b/lib/appwrite/models/o_auth2_slack.rb index 209cc3b5..149cd400 100644 --- a/lib/appwrite/models/o_auth2_slack.rb +++ b/lib/appwrite/models/o_auth2_slack.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Slack.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_spotify.rb b/lib/appwrite/models/o_auth2_spotify.rb index 014d82dc..addf5467 100644 --- a/lib/appwrite/models/o_auth2_spotify.rb +++ b/lib/appwrite/models/o_auth2_spotify.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Spotify.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_stripe.rb b/lib/appwrite/models/o_auth2_stripe.rb index 66604406..4b580c06 100644 --- a/lib/appwrite/models/o_auth2_stripe.rb +++ b/lib/appwrite/models/o_auth2_stripe.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "apiSecretKey" => "" }.merge(map) OAuth2Stripe.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_tradeshift.rb b/lib/appwrite/models/o_auth2_tradeshift.rb index 749c666d..5099f337 100644 --- a/lib/appwrite/models/o_auth2_tradeshift.rb +++ b/lib/appwrite/models/o_auth2_tradeshift.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "oauth2ClientId" => "", "oauth2ClientSecret" => "" }.merge(map) OAuth2Tradeshift.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_twitch.rb b/lib/appwrite/models/o_auth2_twitch.rb index ac7fa8a1..b2f90f4e 100644 --- a/lib/appwrite/models/o_auth2_twitch.rb +++ b/lib/appwrite/models/o_auth2_twitch.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Twitch.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_word_press.rb b/lib/appwrite/models/o_auth2_word_press.rb index 3fab755c..9453b756 100644 --- a/lib/appwrite/models/o_auth2_word_press.rb +++ b/lib/appwrite/models/o_auth2_word_press.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2WordPress.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_x.rb b/lib/appwrite/models/o_auth2_x.rb index d2f771a4..55b32ea6 100644 --- a/lib/appwrite/models/o_auth2_x.rb +++ b/lib/appwrite/models/o_auth2_x.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "customerKey" => "", "secretKey" => "" }.merge(map) OAuth2X.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_yahoo.rb b/lib/appwrite/models/o_auth2_yahoo.rb index 13aea493..1d0819e1 100644 --- a/lib/appwrite/models/o_auth2_yahoo.rb +++ b/lib/appwrite/models/o_auth2_yahoo.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Yahoo.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_yandex.rb b/lib/appwrite/models/o_auth2_yandex.rb index 8373037e..102e0bf4 100644 --- a/lib/appwrite/models/o_auth2_yandex.rb +++ b/lib/appwrite/models/o_auth2_yandex.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Yandex.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_zoho.rb b/lib/appwrite/models/o_auth2_zoho.rb index 792da041..c7bb5db2 100644 --- a/lib/appwrite/models/o_auth2_zoho.rb +++ b/lib/appwrite/models/o_auth2_zoho.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [] }.merge(map) OAuth2Zoho.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_zoom.rb b/lib/appwrite/models/o_auth2_zoom.rb index d7b261ce..97617c2b 100644 --- a/lib/appwrite/models/o_auth2_zoom.rb +++ b/lib/appwrite/models/o_auth2_zoom.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Zoom.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/oauth2_approve.rb b/lib/appwrite/models/oauth2_approve.rb index 748c7880..32e7f309 100644 --- a/lib/appwrite/models/oauth2_approve.rb +++ b/lib/appwrite/models/oauth2_approve.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "redirectUrl" => "" }.merge(map) Oauth2Approve.new( redirect_url: map["redirectUrl"] ) diff --git a/lib/appwrite/models/oauth2_authorize.rb b/lib/appwrite/models/oauth2_authorize.rb index 99f35e8c..269932a6 100644 --- a/lib/appwrite/models/oauth2_authorize.rb +++ b/lib/appwrite/models/oauth2_authorize.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "grantId" => "", "redirectUrl" => "" }.merge(map) Oauth2Authorize.new( grant_id: map["grantId"], redirect_url: map["redirectUrl"] diff --git a/lib/appwrite/models/oauth2_consent.rb b/lib/appwrite/models/oauth2_consent.rb index af8f3ec0..f1080bca 100644 --- a/lib/appwrite/models/oauth2_consent.rb +++ b/lib/appwrite/models/oauth2_consent.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "appId" => "", "cimdUrl" => "", "scopes" => [], "resources" => [], "authorizationDetails" => "[]", "expire" => "" }.merge(map) Oauth2Consent.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/oauth2_consent_list.rb b/lib/appwrite/models/oauth2_consent_list.rb index a6ca3cea..7543e968 100644 --- a/lib/appwrite/models/oauth2_consent_list.rb +++ b/lib/appwrite/models/oauth2_consent_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "consents" => [] }.merge(map) Oauth2ConsentList.new( total: map["total"], consents: map["consents"].map { |it| Oauth2Consent.from(map: it) } diff --git a/lib/appwrite/models/oauth2_consent_token.rb b/lib/appwrite/models/oauth2_consent_token.rb index 6b1bc02a..bc01ac00 100644 --- a/lib/appwrite/models/oauth2_consent_token.rb +++ b/lib/appwrite/models/oauth2_consent_token.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "consentId" => "", "userId" => "", "appId" => "", "cimdUrl" => "", "scopes" => [], "resources" => [], "authorizationDetails" => "[]", "expire" => "" }.merge(map) Oauth2ConsentToken.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/oauth2_consent_token_list.rb b/lib/appwrite/models/oauth2_consent_token_list.rb index edf5aef9..efcc0a05 100644 --- a/lib/appwrite/models/oauth2_consent_token_list.rb +++ b/lib/appwrite/models/oauth2_consent_token_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "tokens" => [] }.merge(map) Oauth2ConsentTokenList.new( total: map["total"], tokens: map["tokens"].map { |it| Oauth2ConsentToken.from(map: it) } diff --git a/lib/appwrite/models/oauth2_device_authorization.rb b/lib/appwrite/models/oauth2_device_authorization.rb index 428970ac..86c07de1 100644 --- a/lib/appwrite/models/oauth2_device_authorization.rb +++ b/lib/appwrite/models/oauth2_device_authorization.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "device_code" => "", "user_code" => "", "verification_uri" => "", "verification_uri_complete" => "", "expires_in" => 0, "interval" => 0 }.merge(map) Oauth2DeviceAuthorization.new( device_code: map["device_code"], user_code: map["user_code"], diff --git a/lib/appwrite/models/oauth2_grant.rb b/lib/appwrite/models/oauth2_grant.rb index df5192bf..d94b15c5 100644 --- a/lib/appwrite/models/oauth2_grant.rb +++ b/lib/appwrite/models/oauth2_grant.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "appId" => "", "scopes" => [], "resources" => [], "authorizationDetails" => "[]", "prompt" => "", "redirectUri" => "", "authTime" => 0, "expire" => "" }.merge(map) Oauth2Grant.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/oauth2_organization.rb b/lib/appwrite/models/oauth2_organization.rb index b69fd0cb..70916f0e 100644 --- a/lib/appwrite/models/oauth2_organization.rb +++ b/lib/appwrite/models/oauth2_organization.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "" }.merge(map) Oauth2Organization.new( id: map["$id"] ) diff --git a/lib/appwrite/models/oauth2_organization_list.rb b/lib/appwrite/models/oauth2_organization_list.rb index 7921605a..1988d853 100644 --- a/lib/appwrite/models/oauth2_organization_list.rb +++ b/lib/appwrite/models/oauth2_organization_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "organizations" => [] }.merge(map) Oauth2OrganizationList.new( total: map["total"], organizations: map["organizations"].map { |it| Oauth2Organization.from(map: it) } diff --git a/lib/appwrite/models/oauth2_par.rb b/lib/appwrite/models/oauth2_par.rb index 18198dc6..17b3ee44 100644 --- a/lib/appwrite/models/oauth2_par.rb +++ b/lib/appwrite/models/oauth2_par.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "request_uri" => "", "expires_in" => 0 }.merge(map) Oauth2PAR.new( request_uri: map["request_uri"], expires_in: map["expires_in"] diff --git a/lib/appwrite/models/oauth2_project.rb b/lib/appwrite/models/oauth2_project.rb index 01b2531c..437421b6 100644 --- a/lib/appwrite/models/oauth2_project.rb +++ b/lib/appwrite/models/oauth2_project.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "region" => "", "endpoint" => "" }.merge(map) Oauth2Project.new( id: map["$id"], region: map["region"], diff --git a/lib/appwrite/models/oauth2_project_list.rb b/lib/appwrite/models/oauth2_project_list.rb index a98a6769..d6338e3c 100644 --- a/lib/appwrite/models/oauth2_project_list.rb +++ b/lib/appwrite/models/oauth2_project_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "projects" => [] }.merge(map) Oauth2ProjectList.new( total: map["total"], projects: map["projects"].map { |it| Oauth2Project.from(map: it) } diff --git a/lib/appwrite/models/oauth2_reject.rb b/lib/appwrite/models/oauth2_reject.rb index 614546e0..29325140 100644 --- a/lib/appwrite/models/oauth2_reject.rb +++ b/lib/appwrite/models/oauth2_reject.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "redirectUrl" => "" }.merge(map) Oauth2Reject.new( redirect_url: map["redirectUrl"] ) diff --git a/lib/appwrite/models/oauth2_token.rb b/lib/appwrite/models/oauth2_token.rb index 59ffd23f..19511db3 100644 --- a/lib/appwrite/models/oauth2_token.rb +++ b/lib/appwrite/models/oauth2_token.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "access_token" => "", "token_type" => "Bearer", "expires_in" => 0, "refresh_token" => "", "scope" => "" }.merge(map) Oauth2Token.new( access_token: map["access_token"], token_type: map["token_type"], diff --git a/lib/appwrite/models/organization.rb b/lib/appwrite/models/organization.rb index aa53b68a..3ef73281 100644 --- a/lib/appwrite/models/organization.rb +++ b/lib/appwrite/models/organization.rb @@ -114,6 +114,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "total" => 0, "budgetAlerts" => [75], "billingPlan" => "tier-0", "billingPlanId" => "tier-0", "billingEmail" => "", "status" => "draft", "markedForDeletion" => false, "platform" => "appwrite", "projects" => [] }.merge(map) Organization.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/passkey.rb b/lib/appwrite/models/passkey.rb index 5098b87b..8cea8129 100644 --- a/lib/appwrite/models/passkey.rb +++ b/lib/appwrite/models/passkey.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "accessedAt" => "" }.merge(map) Passkey.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/passkey_challenge.rb b/lib/appwrite/models/passkey_challenge.rb index b9751184..22f1774c 100644 --- a/lib/appwrite/models/passkey_challenge.rb +++ b/lib/appwrite/models/passkey_challenge.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "passkeyId" => "", "expire" => "", "publicKey" => {} }.merge(map) PasskeyChallenge.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/passkey_list.rb b/lib/appwrite/models/passkey_list.rb index 86a515b7..dffca579 100644 --- a/lib/appwrite/models/passkey_list.rb +++ b/lib/appwrite/models/passkey_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "passkeys" => [] }.merge(map) PasskeyList.new( total: map["total"], passkeys: map["passkeys"].map { |it| Passkey.from(map: it) } diff --git a/lib/appwrite/models/phone.rb b/lib/appwrite/models/phone.rb index 769ea1be..c4d5137c 100644 --- a/lib/appwrite/models/phone.rb +++ b/lib/appwrite/models/phone.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "code" => "", "countryCode" => "", "countryName" => "" }.merge(map) Phone.new( code: map["code"], country_code: map["countryCode"], diff --git a/lib/appwrite/models/phone_list.rb b/lib/appwrite/models/phone_list.rb index d6ad3e14..fea0fea8 100644 --- a/lib/appwrite/models/phone_list.rb +++ b/lib/appwrite/models/phone_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "phones" => [] }.merge(map) PhoneList.new( total: map["total"], phones: map["phones"].map { |it| Phone.from(map: it) } diff --git a/lib/appwrite/models/platform_android.rb b/lib/appwrite/models/platform_android.rb index da5ba79b..3559270e 100644 --- a/lib/appwrite/models/platform_android.rb +++ b/lib/appwrite/models/platform_android.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "applicationId" => "", "fingerprints" => [] }.merge(map) PlatformAndroid.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_apple.rb b/lib/appwrite/models/platform_apple.rb index 06f7aeea..fa95f584 100644 --- a/lib/appwrite/models/platform_apple.rb +++ b/lib/appwrite/models/platform_apple.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "bundleIdentifier" => "" }.merge(map) PlatformApple.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_linux.rb b/lib/appwrite/models/platform_linux.rb index 1442fd5e..a35bc2ca 100644 --- a/lib/appwrite/models/platform_linux.rb +++ b/lib/appwrite/models/platform_linux.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "packageName" => "" }.merge(map) PlatformLinux.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_list.rb b/lib/appwrite/models/platform_list.rb index a51bb20e..c18d4b33 100644 --- a/lib/appwrite/models/platform_list.rb +++ b/lib/appwrite/models/platform_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "platforms" => [] }.merge(map) PlatformList.new( total: map["total"], platforms: map["platforms"] diff --git a/lib/appwrite/models/platform_web.rb b/lib/appwrite/models/platform_web.rb index 8e84519d..a3925665 100644 --- a/lib/appwrite/models/platform_web.rb +++ b/lib/appwrite/models/platform_web.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "hostname" => "" }.merge(map) PlatformWeb.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_windows.rb b/lib/appwrite/models/platform_windows.rb index 560f44d4..07d1e9d5 100644 --- a/lib/appwrite/models/platform_windows.rb +++ b/lib/appwrite/models/platform_windows.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "packageIdentifierName" => "" }.merge(map) PlatformWindows.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/policy_deny_aliased_email.rb b/lib/appwrite/models/policy_deny_aliased_email.rb index f7b755ae..1a05ce5d 100644 --- a/lib/appwrite/models/policy_deny_aliased_email.rb +++ b/lib/appwrite/models/policy_deny_aliased_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyAliasedEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_deny_corporate_email.rb b/lib/appwrite/models/policy_deny_corporate_email.rb index 4bdf38ae..3680ef40 100644 --- a/lib/appwrite/models/policy_deny_corporate_email.rb +++ b/lib/appwrite/models/policy_deny_corporate_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyCorporateEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_deny_disposable_email.rb b/lib/appwrite/models/policy_deny_disposable_email.rb index 23393bea..f3073750 100644 --- a/lib/appwrite/models/policy_deny_disposable_email.rb +++ b/lib/appwrite/models/policy_deny_disposable_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyDisposableEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_deny_free_email.rb b/lib/appwrite/models/policy_deny_free_email.rb index 766573bb..75bca6f0 100644 --- a/lib/appwrite/models/policy_deny_free_email.rb +++ b/lib/appwrite/models/policy_deny_free_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyFreeEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_list.rb b/lib/appwrite/models/policy_list.rb index 077c62f5..7c5be92c 100644 --- a/lib/appwrite/models/policy_list.rb +++ b/lib/appwrite/models/policy_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "policies" => [] }.merge(map) PolicyList.new( total: map["total"], policies: map["policies"] diff --git a/lib/appwrite/models/policy_membership_privacy.rb b/lib/appwrite/models/policy_membership_privacy.rb index 9fa040f1..2a1a56a4 100644 --- a/lib/appwrite/models/policy_membership_privacy.rb +++ b/lib/appwrite/models/policy_membership_privacy.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "userId" => false, "userEmail" => false, "userPhone" => false, "userName" => false, "userMFA" => false, "userAccessedAt" => false }.merge(map) PolicyMembershipPrivacy.new( id: map["$id"], user_id: map["userId"], diff --git a/lib/appwrite/models/policy_mfa_factors.rb b/lib/appwrite/models/policy_mfa_factors.rb index e49890a8..601ef66d 100644 --- a/lib/appwrite/models/policy_mfa_factors.rb +++ b/lib/appwrite/models/policy_mfa_factors.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "totp" => true, "email" => true, "phone" => true, "custom" => false }.merge(map) PolicyMfaFactors.new( id: map["$id"], totp: map["totp"], diff --git a/lib/appwrite/models/policy_passkey.rb b/lib/appwrite/models/policy_passkey.rb index f9cb6701..62bced03 100644 --- a/lib/appwrite/models/policy_passkey.rb +++ b/lib/appwrite/models/policy_passkey.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "rpId" => "", "origins" => [] }.merge(map) PolicyPasskey.new( id: map["$id"], rp_id: map["rpId"], diff --git a/lib/appwrite/models/policy_password_dictionary.rb b/lib/appwrite/models/policy_password_dictionary.rb index 38423bc4..b72d0caa 100644 --- a/lib/appwrite/models/policy_password_dictionary.rb +++ b/lib/appwrite/models/policy_password_dictionary.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyPasswordDictionary.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_password_history.rb b/lib/appwrite/models/policy_password_history.rb index e2d4b842..f5253d15 100644 --- a/lib/appwrite/models/policy_password_history.rb +++ b/lib/appwrite/models/policy_password_history.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "total" => 0 }.merge(map) PolicyPasswordHistory.new( id: map["$id"], total: map["total"] diff --git a/lib/appwrite/models/policy_password_personal_data.rb b/lib/appwrite/models/policy_password_personal_data.rb index 7e2c290e..2be97bd8 100644 --- a/lib/appwrite/models/policy_password_personal_data.rb +++ b/lib/appwrite/models/policy_password_personal_data.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyPasswordPersonalData.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_password_strength.rb b/lib/appwrite/models/policy_password_strength.rb index c2bf28fb..1240c6a0 100644 --- a/lib/appwrite/models/policy_password_strength.rb +++ b/lib/appwrite/models/policy_password_strength.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "min" => 8, "uppercase" => false, "lowercase" => false, "number" => false, "symbols" => false }.merge(map) PolicyPasswordStrength.new( id: map["$id"], min: map["min"], diff --git a/lib/appwrite/models/policy_session_alert.rb b/lib/appwrite/models/policy_session_alert.rb index 74ee3fa2..7ef6a816 100644 --- a/lib/appwrite/models/policy_session_alert.rb +++ b/lib/appwrite/models/policy_session_alert.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicySessionAlert.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_session_duration.rb b/lib/appwrite/models/policy_session_duration.rb index f23f26e9..2928b255 100644 --- a/lib/appwrite/models/policy_session_duration.rb +++ b/lib/appwrite/models/policy_session_duration.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "duration" => 31536000 }.merge(map) PolicySessionDuration.new( id: map["$id"], duration: map["duration"] diff --git a/lib/appwrite/models/policy_session_invalidation.rb b/lib/appwrite/models/policy_session_invalidation.rb index 4c7b0a2e..6ec72c3b 100644 --- a/lib/appwrite/models/policy_session_invalidation.rb +++ b/lib/appwrite/models/policy_session_invalidation.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => true }.merge(map) PolicySessionInvalidation.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_session_limit.rb b/lib/appwrite/models/policy_session_limit.rb index 2c3783d8..193d81b5 100644 --- a/lib/appwrite/models/policy_session_limit.rb +++ b/lib/appwrite/models/policy_session_limit.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "total" => 0 }.merge(map) PolicySessionLimit.new( id: map["$id"], total: map["total"] diff --git a/lib/appwrite/models/policy_user_limit.rb b/lib/appwrite/models/policy_user_limit.rb index b5554c19..1275753d 100644 --- a/lib/appwrite/models/policy_user_limit.rb +++ b/lib/appwrite/models/policy_user_limit.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "total" => 0 }.merge(map) PolicyUserLimit.new( id: map["$id"], total: map["total"] diff --git a/lib/appwrite/models/postgres_extension.rb b/lib/appwrite/models/postgres_extension.rb index 6ae09339..e1c5f081 100644 --- a/lib/appwrite/models/postgres_extension.rb +++ b/lib/appwrite/models/postgres_extension.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "name" => "", "description" => "", "category" => "" }.merge(map) PostgresExtension.new( key: map["key"], name: map["name"], diff --git a/lib/appwrite/models/presence.rb b/lib/appwrite/models/presence.rb index dabfb838..577da3cc 100644 --- a/lib/appwrite/models/presence.rb +++ b/lib/appwrite/models/presence.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "userId" => "", "source" => "" }.merge(map) Presence.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/presence_list.rb b/lib/appwrite/models/presence_list.rb index 01fa5bcb..b43ba834 100644 --- a/lib/appwrite/models/presence_list.rb +++ b/lib/appwrite/models/presence_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "presences" => [] }.merge(map) PresenceList.new( total: map["total"], presences: map["presences"].map { |it| Presence.from(map: it) } diff --git a/lib/appwrite/models/program.rb b/lib/appwrite/models/program.rb index db9215e1..7705670c 100644 --- a/lib/appwrite/models/program.rb +++ b/lib/appwrite/models/program.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "title" => "", "description" => "", "tag" => "", "icon" => "", "url" => "", "active" => true, "external" => true, "billingPlanId" => "" }.merge(map) Program.new( id: map["$id"], title: map["title"], diff --git a/lib/appwrite/models/project.rb b/lib/appwrite/models/project.rb index b03fcbc6..3af3e1dd 100644 --- a/lib/appwrite/models/project.rb +++ b/lib/appwrite/models/project.rb @@ -9,7 +9,6 @@ class Project attr_reader :name attr_reader :team_id attr_reader :region - attr_reader :dev_keys attr_reader :smtp_enabled attr_reader :smtp_sender_name attr_reader :smtp_sender_email @@ -60,7 +59,6 @@ def initialize( name:, team_id:, region:, - dev_keys:, smtp_enabled:, smtp_sender_name:, smtp_sender_email:, @@ -88,20 +86,20 @@ def initialize( mcp_accessed_at:, o_auth2_server_enabled:, o_auth2_server_authorization_url:, - o_auth2_server_scopes:, - o_auth2_server_default_scopes:, - o_auth2_server_installation_scopes:, - o_auth2_server_authorization_details_types:, - o_auth2_server_access_token_duration:, - 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_scopes: [], + o_auth2_server_default_scopes: [], + o_auth2_server_installation_scopes: [], + o_auth2_server_authorization_details_types: [], + o_auth2_server_access_token_duration: 0, + o_auth2_server_refresh_token_duration: 0, + o_auth2_server_public_access_token_duration: 0, + o_auth2_server_public_refresh_token_duration: 0, + o_auth2_server_installation_access_token_duration: 0, o_auth2_server_confidential_pkce:, o_auth2_server_verification_url:, - o_auth2_server_user_code_length:, - o_auth2_server_user_code_format:, - o_auth2_server_device_code_duration:, + o_auth2_server_user_code_length: 8, + o_auth2_server_user_code_format: "alphanumeric", + o_auth2_server_device_code_duration: 600, o_auth2_server_discovery_url: ) @id = id @@ -110,7 +108,6 @@ def initialize( @name = name @team_id = team_id @region = region - @dev_keys = dev_keys @smtp_enabled = smtp_enabled @smtp_sender_name = smtp_sender_name @smtp_sender_email = smtp_sender_email @@ -156,6 +153,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "teamId" => "", "region" => "fra", "smtpEnabled" => false, "smtpSenderName" => "", "smtpSenderEmail" => "", "smtpReplyToName" => "", "smtpReplyToEmail" => "", "smtpHost" => "", "smtpPort" => 0, "smtpUsername" => "", "smtpPassword" => "", "smtpSecure" => "", "pingCount" => 0, "pingedAt" => "", "labels" => [], "status" => "active", "onboarding" => {}, "authMethods" => [], "services" => [], "protocols" => [], "blocks" => [], "consoleAccessedAt" => "" }.merge(map) Project.new( id: map["$id"], created_at: map["$createdAt"], @@ -163,7 +161,6 @@ def self.from(map:) name: map["name"], team_id: map["teamId"], region: map["region"], - dev_keys: map["devKeys"].map { |it| DevKey.from(map: it) }, smtp_enabled: map["smtpEnabled"], smtp_sender_name: map["smtpSenderName"], smtp_sender_email: map["smtpSenderEmail"], @@ -217,7 +214,6 @@ def to_map "name": @name, "teamId": @team_id, "region": @region, - "devKeys": @dev_keys.map { |it| it.to_map }, "smtpEnabled": @smtp_enabled, "smtpSenderName": @smtp_sender_name, "smtpSenderEmail": @smtp_sender_email, diff --git a/lib/appwrite/models/project_auth_method.rb b/lib/appwrite/models/project_auth_method.rb index 98c67156..23162ba9 100644 --- a/lib/appwrite/models/project_auth_method.rb +++ b/lib/appwrite/models/project_auth_method.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => true }.merge(map) ProjectAuthMethod.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/project_list.rb b/lib/appwrite/models/project_list.rb index 552309a5..f2fd282a 100644 --- a/lib/appwrite/models/project_list.rb +++ b/lib/appwrite/models/project_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "projects" => [] }.merge(map) ProjectList.new( total: map["total"], projects: map["projects"].map { |it| Project.from(map: it) } diff --git a/lib/appwrite/models/project_protocol.rb b/lib/appwrite/models/project_protocol.rb index 58448214..a3071c87 100644 --- a/lib/appwrite/models/project_protocol.rb +++ b/lib/appwrite/models/project_protocol.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => true }.merge(map) ProjectProtocol.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/project_service.rb b/lib/appwrite/models/project_service.rb index 128c31b0..a4ea7343 100644 --- a/lib/appwrite/models/project_service.rb +++ b/lib/appwrite/models/project_service.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => true }.merge(map) ProjectService.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/provider.rb b/lib/appwrite/models/provider.rb index 80d6c956..90a53b7c 100644 --- a/lib/appwrite/models/provider.rb +++ b/lib/appwrite/models/provider.rb @@ -22,7 +22,7 @@ def initialize( enabled:, type:, credentials:, - options: + options: {} ) @id = id @created_at = created_at @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "provider" => "", "enabled" => true, "type" => "", "credentials" => {} }.merge(map) Provider.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/provider_list.rb b/lib/appwrite/models/provider_list.rb index 32f7da98..46909a15 100644 --- a/lib/appwrite/models/provider_list.rb +++ b/lib/appwrite/models/provider_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "providers" => [] }.merge(map) ProviderList.new( total: map["total"], providers: map["providers"].map { |it| Provider.from(map: it) } diff --git a/lib/appwrite/models/proxy_invalidation.rb b/lib/appwrite/models/proxy_invalidation.rb index 584669ac..872f90e6 100644 --- a/lib/appwrite/models/proxy_invalidation.rb +++ b/lib/appwrite/models/proxy_invalidation.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "domain" => "", "type" => "", "reference" => "", "status" => "" }.merge(map) ProxyInvalidation.new( domain: map["domain"], type: map["type"], diff --git a/lib/appwrite/models/proxy_rule.rb b/lib/appwrite/models/proxy_rule.rb index e37a6e6d..76495fef 100644 --- a/lib/appwrite/models/proxy_rule.rb +++ b/lib/appwrite/models/proxy_rule.rb @@ -18,6 +18,7 @@ class ProxyRule attr_reader :status attr_reader :logs attr_reader :renew_at + attr_reader :protocol def initialize( id:, @@ -34,7 +35,8 @@ def initialize( deployment_vcs_provider_branch:, status:, logs:, - renew_at: + renew_at:, + protocol: ) @id = id @created_at = created_at @@ -51,9 +53,11 @@ def initialize( @status = validate_status(status) @logs = logs @renew_at = renew_at + @protocol = validate_protocol(protocol) end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "domain" => "", "type" => "", "trigger" => "", "redirectUrl" => "", "redirectStatusCode" => 301, "deploymentId" => "", "deploymentResourceId" => "", "deploymentVcsProviderBranch" => "", "status" => "unverified", "logs" => "", "protocol" => "http" }.merge(map) ProxyRule.new( id: map["$id"], created_at: map["$createdAt"], @@ -69,7 +73,8 @@ def self.from(map:) deployment_vcs_provider_branch: map["deploymentVcsProviderBranch"], status: map["status"], logs: map["logs"], - renew_at: map["renewAt"] + renew_at: map["renewAt"], + protocol: map["protocol"] ) end @@ -89,7 +94,8 @@ def to_map "deploymentVcsProviderBranch": @deployment_vcs_provider_branch, "status": @status, "logs": @logs, - "renewAt": @renew_at + "renewAt": @renew_at, + "protocol": @protocol } end @@ -122,6 +128,19 @@ def validate_status(status) status end + + def validate_protocol(protocol) + valid_protocol = [ + Appwrite::Enums::ProxyRuleProtocol::HTTP, + Appwrite::Enums::ProxyRuleProtocol::SMTP, + ] + + unless valid_protocol.include?(protocol) + raise ArgumentError, "Invalid " + protocol + ". Must be one of: " + valid_protocol.join(', ') + end + + protocol + end end end end diff --git a/lib/appwrite/models/proxy_rule_list.rb b/lib/appwrite/models/proxy_rule_list.rb index 24f99239..3f324ae8 100644 --- a/lib/appwrite/models/proxy_rule_list.rb +++ b/lib/appwrite/models/proxy_rule_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "rules" => [] }.merge(map) ProxyRuleList.new( total: map["total"], rules: map["rules"].map { |it| ProxyRule.from(map: it) } diff --git a/lib/appwrite/models/report.rb b/lib/appwrite/models/report.rb index b3912319..e39bde63 100644 --- a/lib/appwrite/models/report.rb +++ b/lib/appwrite/models/report.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "type" => "", "title" => "", "summary" => "", "targetType" => "", "target" => "", "categories" => [], "insights" => [] }.merge(map) Report.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/report_list.rb b/lib/appwrite/models/report_list.rb index 8cdd69a0..40a7cee2 100644 --- a/lib/appwrite/models/report_list.rb +++ b/lib/appwrite/models/report_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "reports" => [] }.merge(map) ReportList.new( total: map["total"], reports: map["reports"].map { |it| Report.from(map: it) } diff --git a/lib/appwrite/models/resource_token.rb b/lib/appwrite/models/resource_token.rb index 61c2b49e..a5d39ace 100644 --- a/lib/appwrite/models/resource_token.rb +++ b/lib/appwrite/models/resource_token.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "resourceId" => "", "resourceType" => "", "expire" => "", "secret" => "", "accessedAt" => "" }.merge(map) ResourceToken.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/resource_token_list.rb b/lib/appwrite/models/resource_token_list.rb index 928b7825..a07536c6 100644 --- a/lib/appwrite/models/resource_token_list.rb +++ b/lib/appwrite/models/resource_token_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "tokens" => [] }.merge(map) ResourceTokenList.new( total: map["total"], tokens: map["tokens"].map { |it| ResourceToken.from(map: it) } diff --git a/lib/appwrite/models/row.rb b/lib/appwrite/models/row.rb index c19c0445..2407b2ca 100644 --- a/lib/appwrite/models/row.rb +++ b/lib/appwrite/models/row.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$sequence" => "", "$tableId" => "", "$databaseId" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [] }.merge(map) Row.new( id: map["$id"], sequence: map["$sequence"], diff --git a/lib/appwrite/models/row_list.rb b/lib/appwrite/models/row_list.rb index debd9e50..55bcab78 100644 --- a/lib/appwrite/models/row_list.rb +++ b/lib/appwrite/models/row_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "rows" => [] }.merge(map) RowList.new( total: map["total"], rows: map["rows"].map { |it| Row.from(map: it) } diff --git a/lib/appwrite/models/runtime.rb b/lib/appwrite/models/runtime.rb index 4a09aa27..840663d4 100644 --- a/lib/appwrite/models/runtime.rb +++ b/lib/appwrite/models/runtime.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "key" => "", "name" => "", "version" => "", "base" => "", "image" => "", "logo" => "", "supports" => [] }.merge(map) Runtime.new( id: map["$id"], key: map["key"], diff --git a/lib/appwrite/models/runtime_list.rb b/lib/appwrite/models/runtime_list.rb index 5b69b4a6..018a5bf6 100644 --- a/lib/appwrite/models/runtime_list.rb +++ b/lib/appwrite/models/runtime_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "runtimes" => [] }.merge(map) RuntimeList.new( total: map["total"], runtimes: map["runtimes"].map { |it| Runtime.from(map: it) } diff --git a/lib/appwrite/models/session.rb b/lib/appwrite/models/session.rb index 762ee427..0777f369 100644 --- a/lib/appwrite/models/session.rb +++ b/lib/appwrite/models/session.rb @@ -96,6 +96,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "expire" => "", "provider" => "", "providerUid" => "", "providerAccessToken" => "", "providerAccessTokenExpiry" => "", "providerRefreshToken" => "", "ip" => "", "osCode" => "", "osName" => "", "osVersion" => "", "clientType" => "", "clientCode" => "", "clientName" => "", "clientVersion" => "", "clientEngine" => "", "clientEngineVersion" => "", "deviceName" => "", "deviceBrand" => "", "deviceModel" => "", "countryCode" => "", "countryName" => "", "current" => false, "factors" => [], "secret" => "", "mfaUpdatedAt" => "" }.merge(map) Session.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/session_list.rb b/lib/appwrite/models/session_list.rb index 320cefec..b55a7b94 100644 --- a/lib/appwrite/models/session_list.rb +++ b/lib/appwrite/models/session_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "sessions" => [] }.merge(map) SessionList.new( total: map["total"], sessions: map["sessions"].map { |it| Session.from(map: it) } diff --git a/lib/appwrite/models/site.rb b/lib/appwrite/models/site.rb index 94e80f00..60300827 100644 --- a/lib/appwrite/models/site.rb +++ b/lib/appwrite/models/site.rb @@ -114,6 +114,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "enabled" => true, "live" => true, "logging" => true, "framework" => "", "deploymentRetention" => 0, "deploymentId" => "", "deploymentCreatedAt" => "", "deploymentScreenshotLight" => "", "deploymentScreenshotDark" => "", "latestDeploymentId" => "", "latestDeploymentCreatedAt" => "", "latestDeploymentStatus" => "", "scopes" => [], "vars" => [], "timeout" => 15, "installCommand" => "", "buildCommand" => "", "startCommand" => "", "outputDirectory" => "", "installationId" => "", "providerRepositoryId" => "", "providerBranch" => "", "providerRootDirectory" => "", "providerSilentMode" => false, "providerBranches" => [], "providerPaths" => [], "buildSpecification" => "s-1vcpu-512mb", "runtimeSpecification" => "s-1vcpu-512mb", "buildRuntime" => "" }.merge(map) Site.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/site_list.rb b/lib/appwrite/models/site_list.rb index 51fb319d..f9537cc7 100644 --- a/lib/appwrite/models/site_list.rb +++ b/lib/appwrite/models/site_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "sites" => [] }.merge(map) SiteList.new( total: map["total"], sites: map["sites"].map { |it| Site.from(map: it) } diff --git a/lib/appwrite/models/specification.rb b/lib/appwrite/models/specification.rb index e9ff5467..b8606f25 100644 --- a/lib/appwrite/models/specification.rb +++ b/lib/appwrite/models/specification.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "memory" => 0, "cpus" => 0, "enabled" => false, "slug" => "" }.merge(map) Specification.new( memory: map["memory"], cpus: map["cpus"], diff --git a/lib/appwrite/models/specification_list.rb b/lib/appwrite/models/specification_list.rb index 8212053d..f79e4e31 100644 --- a/lib/appwrite/models/specification_list.rb +++ b/lib/appwrite/models/specification_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "specifications" => [] }.merge(map) SpecificationList.new( total: map["total"], specifications: map["specifications"].map { |it| Specification.from(map: it) } diff --git a/lib/appwrite/models/subscriber.rb b/lib/appwrite/models/subscriber.rb index 318baaab..b2e07da3 100644 --- a/lib/appwrite/models/subscriber.rb +++ b/lib/appwrite/models/subscriber.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "targetId" => "", "userId" => "", "userName" => "", "topicId" => "", "providerType" => "" }.merge(map) Subscriber.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/subscriber_list.rb b/lib/appwrite/models/subscriber_list.rb index 01373385..904bf7d0 100644 --- a/lib/appwrite/models/subscriber_list.rb +++ b/lib/appwrite/models/subscriber_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "subscribers" => [] }.merge(map) SubscriberList.new( total: map["total"], subscribers: map["subscribers"].map { |it| Subscriber.from(map: it) } diff --git a/lib/appwrite/models/table.rb b/lib/appwrite/models/table.rb index 2a7e4649..69851a39 100644 --- a/lib/appwrite/models/table.rb +++ b/lib/appwrite/models/table.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "databaseId" => "", "name" => "", "enabled" => true, "rowSecurity" => false, "columns" => [], "indexes" => [], "bytesMax" => 0, "bytesUsed" => 0 }.merge(map) Table.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/table_list.rb b/lib/appwrite/models/table_list.rb index 034d7fb3..98d96311 100644 --- a/lib/appwrite/models/table_list.rb +++ b/lib/appwrite/models/table_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "tables" => [] }.merge(map) TableList.new( total: map["total"], tables: map["tables"].map { |it| Table.from(map: it) } diff --git a/lib/appwrite/models/target.rb b/lib/appwrite/models/target.rb index 56e90755..8d11a1fe 100644 --- a/lib/appwrite/models/target.rb +++ b/lib/appwrite/models/target.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "userId" => "", "providerType" => "", "identifier" => "", "expired" => false }.merge(map) Target.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/target_list.rb b/lib/appwrite/models/target_list.rb index 9ccd7705..1c7fe0e8 100644 --- a/lib/appwrite/models/target_list.rb +++ b/lib/appwrite/models/target_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "targets" => [] }.merge(map) TargetList.new( total: map["total"], targets: map["targets"].map { |it| Target.from(map: it) } diff --git a/lib/appwrite/models/team.rb b/lib/appwrite/models/team.rb index d08f183f..06bcaf72 100644 --- a/lib/appwrite/models/team.rb +++ b/lib/appwrite/models/team.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "total" => 0 }.merge(map) Team.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/team_list.rb b/lib/appwrite/models/team_list.rb index e02efc9c..01300672 100644 --- a/lib/appwrite/models/team_list.rb +++ b/lib/appwrite/models/team_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "teams" => [] }.merge(map) TeamList.new( total: map["total"], teams: map["teams"].map { |it| Team.from(map: it) } diff --git a/lib/appwrite/models/token.rb b/lib/appwrite/models/token.rb index b3f539af..bf6c51a9 100644 --- a/lib/appwrite/models/token.rb +++ b/lib/appwrite/models/token.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "secret" => "", "expire" => "", "phrase" => "" }.merge(map) Token.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/token_secret.rb b/lib/appwrite/models/token_secret.rb index 4744532f..31ef131b 100644 --- a/lib/appwrite/models/token_secret.rb +++ b/lib/appwrite/models/token_secret.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "secret" => "", "expire" => "", "phrase" => "" }.merge(map) TokenSecret.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/topic.rb b/lib/appwrite/models/topic.rb index 247284d8..9f7c6a6c 100644 --- a/lib/appwrite/models/topic.rb +++ b/lib/appwrite/models/topic.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "emailTotal" => 0, "smsTotal" => 0, "pushTotal" => 0, "subscribe" => ["users"] }.merge(map) Topic.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/topic_list.rb b/lib/appwrite/models/topic_list.rb index e1b8c6d0..9542c588 100644 --- a/lib/appwrite/models/topic_list.rb +++ b/lib/appwrite/models/topic_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "topics" => [] }.merge(map) TopicList.new( total: map["total"], topics: map["topics"].map { |it| Topic.from(map: it) } diff --git a/lib/appwrite/models/transaction.rb b/lib/appwrite/models/transaction.rb index 481c25c9..e35a80fa 100644 --- a/lib/appwrite/models/transaction.rb +++ b/lib/appwrite/models/transaction.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "status" => "pending", "operations" => 0, "expiresAt" => "" }.merge(map) Transaction.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/transaction_list.rb b/lib/appwrite/models/transaction_list.rb index 17234abd..0db83c65 100644 --- a/lib/appwrite/models/transaction_list.rb +++ b/lib/appwrite/models/transaction_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "transactions" => [] }.merge(map) TransactionList.new( total: map["total"], transactions: map["transactions"].map { |it| Transaction.from(map: it) } diff --git a/lib/appwrite/models/usage_billing_plan.rb b/lib/appwrite/models/usage_billing_plan.rb index be1d81f6..0a181abb 100644 --- a/lib/appwrite/models/usage_billing_plan.rb +++ b/lib/appwrite/models/usage_billing_plan.rb @@ -43,32 +43,32 @@ def initialize( def self.from(map:) UsageBillingPlan.new( - bandwidth: AdditionalResource.from(map: map["bandwidth"]), - executions: AdditionalResource.from(map: map["executions"]), + bandwidth: map["bandwidth"].nil? ? nil : AdditionalResource.from(map: map["bandwidth"]), + executions: map["executions"].nil? ? nil : AdditionalResource.from(map: map["executions"]), member: map["member"].nil? ? nil : AdditionalResource.from(map: map["member"]), - realtime: AdditionalResource.from(map: map["realtime"]), - realtime_messages: AdditionalResource.from(map: map["realtimeMessages"]), + realtime: map["realtime"].nil? ? nil : AdditionalResource.from(map: map["realtime"]), + realtime_messages: map["realtimeMessages"].nil? ? nil : AdditionalResource.from(map: map["realtimeMessages"]), realtime_bandwidth: map["realtimeBandwidth"].nil? ? nil : AdditionalResource.from(map: map["realtimeBandwidth"]), - storage: AdditionalResource.from(map: map["storage"]), - users: AdditionalResource.from(map: map["users"]), - gb_hours: AdditionalResource.from(map: map["GBHours"]), - image_transformations: AdditionalResource.from(map: map["imageTransformations"]), + storage: map["storage"].nil? ? nil : AdditionalResource.from(map: map["storage"]), + users: map["users"].nil? ? nil : AdditionalResource.from(map: map["users"]), + gb_hours: map["GBHours"].nil? ? nil : AdditionalResource.from(map: map["GBHours"]), + image_transformations: map["imageTransformations"].nil? ? nil : AdditionalResource.from(map: map["imageTransformations"]), credits: map["credits"].nil? ? nil : AdditionalResource.from(map: map["credits"]) ) end def to_map { - "bandwidth": @bandwidth.to_map, - "executions": @executions.to_map, + "bandwidth": @bandwidth&.to_map, + "executions": @executions&.to_map, "member": @member&.to_map, - "realtime": @realtime.to_map, - "realtimeMessages": @realtime_messages.to_map, + "realtime": @realtime&.to_map, + "realtimeMessages": @realtime_messages&.to_map, "realtimeBandwidth": @realtime_bandwidth&.to_map, - "storage": @storage.to_map, - "users": @users.to_map, - "GBHours": @gb_hours.to_map, - "imageTransformations": @image_transformations.to_map, + "storage": @storage&.to_map, + "users": @users&.to_map, + "GBHours": @gb_hours&.to_map, + "imageTransformations": @image_transformations&.to_map, "credits": @credits&.to_map } end diff --git a/lib/appwrite/models/user.rb b/lib/appwrite/models/user.rb index 9586ee8c..240a4f11 100644 --- a/lib/appwrite/models/user.rb +++ b/lib/appwrite/models/user.rb @@ -90,6 +90,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "registration" => "", "status" => true, "labels" => [], "passwordUpdate" => "", "email" => "", "phone" => "", "emailVerification" => false, "phoneVerification" => false, "mfa" => false, "targets" => [], "accessedAt" => "" }.merge(map) User.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/user_list.rb b/lib/appwrite/models/user_list.rb index 79c4c6d3..62660196 100644 --- a/lib/appwrite/models/user_list.rb +++ b/lib/appwrite/models/user_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "users" => [] }.merge(map) UserList.new( total: map["total"], users: map["users"].map { |it| User.from(map: it) } diff --git a/lib/appwrite/models/variable.rb b/lib/appwrite/models/variable.rb index 1c14a73d..d5722127 100644 --- a/lib/appwrite/models/variable.rb +++ b/lib/appwrite/models/variable.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "key" => "", "value" => "", "secret" => false, "resourceType" => "", "resourceId" => "" }.merge(map) Variable.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/variable_list.rb b/lib/appwrite/models/variable_list.rb index 6c36b9d1..bfe9230f 100644 --- a/lib/appwrite/models/variable_list.rb +++ b/lib/appwrite/models/variable_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "variables" => [] }.merge(map) VariableList.new( total: map["total"], variables: map["variables"].map { |it| Variable.from(map: it) } diff --git a/lib/appwrite/models/vectorsdb_collection.rb b/lib/appwrite/models/vectorsdb_collection.rb index fc878665..0f3842c3 100644 --- a/lib/appwrite/models/vectorsdb_collection.rb +++ b/lib/appwrite/models/vectorsdb_collection.rb @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "databaseId" => "", "name" => "", "enabled" => true, "documentSecurity" => false, "attributes" => [], "indexes" => [], "bytesMax" => 0, "bytesUsed" => 0, "dimension" => 0 }.merge(map) VectorsdbCollection.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/vectorsdb_collection_list.rb b/lib/appwrite/models/vectorsdb_collection_list.rb index e933696b..e38a9a4d 100644 --- a/lib/appwrite/models/vectorsdb_collection_list.rb +++ b/lib/appwrite/models/vectorsdb_collection_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "collections" => [] }.merge(map) VectorsdbCollectionList.new( total: map["total"], collections: map["collections"].map { |it| VectorsdbCollection.from(map: it) } diff --git a/lib/appwrite/models/webhook.rb b/lib/appwrite/models/webhook.rb index 5e418078..333fc55b 100644 --- a/lib/appwrite/models/webhook.rb +++ b/lib/appwrite/models/webhook.rb @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "url" => "", "events" => [], "tls" => true, "authUsername" => "", "authPassword" => "", "secret" => "", "enabled" => true, "logs" => "", "attempts" => 0 }.merge(map) Webhook.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/webhook_list.rb b/lib/appwrite/models/webhook_list.rb index 1df070b9..ee1af6f5 100644 --- a/lib/appwrite/models/webhook_list.rb +++ b/lib/appwrite/models/webhook_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "webhooks" => [] }.merge(map) WebhookList.new( total: map["total"], webhooks: map["webhooks"].map { |it| Webhook.from(map: it) } diff --git a/lib/appwrite/query.rb b/lib/appwrite/query.rb index 3312d81f..a922d750 100644 --- a/lib/appwrite/query.rb +++ b/lib/appwrite/query.rb @@ -216,6 +216,15 @@ def elem_match(attribute, queries) return Query.new("elemMatch", attribute, queries.map { |query| JSON.parse(query) }).to_s end + # Constrain populated related documents on a relationship attribute. + # + # @param attribute [String] The relationship attribute to query. + # @param queries [Array] Filter, order, select, and pagination queries applied to related documents. + # @return [String] The query string. + def relationship(attribute, queries) + return Query.new("relationship", attribute, queries.map { |query| JSON.parse(query) }).to_s + end + def distance_equal(attribute, values, distance, meters = true) return Query.new("distanceEqual", attribute, [[values, distance, meters]]).to_s end @@ -275,6 +284,187 @@ def touches(attribute, values) def not_touches(attribute, values) return Query.new("notTouches", attribute, [values]).to_s end + + def count(attribute = '*', alias_name = '') + return Query.new("count", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def count_distinct(attribute, alias_name = '') + return Query.new("countDistinct", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def sum(attribute, alias_name = '') + return Query.new("sum", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def avg(attribute, alias_name = '') + return Query.new("avg", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def min(attribute, alias_name = '') + return Query.new("min", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def max(attribute, alias_name = '') + return Query.new("max", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def stddev(attribute, alias_name = '') + return Query.new("stddev", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def stddev_pop(attribute, alias_name = '') + return Query.new("stddevPop", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def stddev_samp(attribute, alias_name = '') + return Query.new("stddevSamp", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def variance(attribute, alias_name = '') + return Query.new("variance", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def var_pop(attribute, alias_name = '') + return Query.new("varPop", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def var_samp(attribute, alias_name = '') + return Query.new("varSamp", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def bit_and(attribute, alias_name = '') + return Query.new("bitAnd", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def bit_or(attribute, alias_name = '') + return Query.new("bitOr", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def bit_xor(attribute, alias_name = '') + return Query.new("bitXor", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def group_by(attributes) + return Query.new("groupBy", nil, attributes).to_s + end + + def having(queries) + return Query.new("having", nil, queries.map { |query| JSON.parse(query) }).to_s + end + + def distinct() + return Query.new("distinct", nil, nil).to_s + end + + def on(left, right, operator = '=') + return Query.new("on", nil, [left, operator, right]).to_s + end + + def join(table, left, right = '', operator = '=', alias_name = '') + return create_join("join", table, left, right, operator, alias_name) + end + + def left_join(table, left, right = '', operator = '=', alias_name = '') + return create_join("leftJoin", table, left, right, operator, alias_name) + end + + def right_join(table, left, right = '', operator = '=', alias_name = '') + return create_join("rightJoin", table, left, right, operator, alias_name) + end + + def full_outer_join(table, left, right = '', operator = '=', alias_name = '') + return create_join("fullOuterJoin", table, left, right, operator, alias_name) + end + + def cross_join(table, alias_name = '') + return Query.new("crossJoin", table, alias_name != '' ? alias_name : nil).to_s + end + + def covers(attribute, values) + return Query.new("covers", attribute, [values]).to_s + end + + def not_covers(attribute, values) + return Query.new("notCovers", attribute, [values]).to_s + end + + def spatial_equals(attribute, values) + return Query.new("spatialEquals", attribute, [values]).to_s + end + + def not_spatial_equals(attribute, values) + return Query.new("notSpatialEquals", attribute, [values]).to_s + end + + def page(page, per_page = 25) + if page < 1 + raise ArgumentError, "Page must be >= 1, got #{page}" + end + if per_page < 1 + raise ArgumentError, "Per page must be >= 1, got #{per_page}" + end + + return [ + limit(per_page), + offset((page - 1) * per_page), + ] + end + + def builder + return Builder.new + end + + def _flatten(value) + return value.build if value.is_a?(Builder) + return value.to_s if value.is_a?(Query) + return value unless value.is_a?(Array) + + out = [] + changed = false + value.each do |item| + flat = _flatten(item) + if item.is_a?(Builder) || item.is_a?(Query) + if flat.is_a?(Array) + out.concat(flat) + else + out << flat + end + changed = true + next + end + changed = true if flat != item + out << flat + end + + changed ? out : value + end + + private + + def create_join(method, table, left, right, operator, alias_name) + return nested_join(method, table, '', left) if left.is_a?(Array) + return nested_join(method, table, left, right) if right.is_a?(Array) + + return join_query(method, table, left, right, operator, alias_name) + end + + def nested_join(method, table, alias_name, on) + values = [] + values << alias_name if alias_name != '' + on.each { |query| values << JSON.parse(query) } + + return Query.new(method, table, values).to_s + end + + def join_query(method, table, left, right, operator, alias_name) + values = [left, operator, right] + values << alias_name if alias_name != '' + + return Query.new(method, table, values).to_s + end end end + + require_relative 'query/builder' end diff --git a/lib/appwrite/query/builder.rb b/lib/appwrite/query/builder.rb new file mode 100644 index 00000000..8f914b0e --- /dev/null +++ b/lib/appwrite/query/builder.rb @@ -0,0 +1,361 @@ +require 'json' + +module Appwrite + class Query::Builder + def initialize + @queries = [] + end + + def build + return @queries.dup + end + + def equal(attribute, value) + return push(Query.equal(attribute, value)) + end + + def not_equal(attribute, value) + return push(Query.not_equal(attribute, value)) + end + + def less_than(attribute, value) + return push(Query.less_than(attribute, value)) + end + + def less_than_equal(attribute, value) + return push(Query.less_than_equal(attribute, value)) + end + + def greater_than(attribute, value) + return push(Query.greater_than(attribute, value)) + end + + def greater_than_equal(attribute, value) + return push(Query.greater_than_equal(attribute, value)) + end + + def search(attribute, value) + return push(Query.search(attribute, value)) + end + + def is_null(attribute) + return push(Query.is_null(attribute)) + end + + def is_not_null(attribute) + return push(Query.is_not_null(attribute)) + end + + def between(attribute, start, ending) + return push(Query.between(attribute, start, ending)) + end + + def starts_with(attribute, value) + return push(Query.starts_with(attribute, value)) + end + + def ends_with(attribute, value) + return push(Query.ends_with(attribute, value)) + end + + def select(attributes) + return push(Query.select(attributes)) + end + + def cursor_after(id) + return push(Query.cursor_after(id)) + end + + def cursor_before(id) + return push(Query.cursor_before(id)) + end + + def order_asc(attribute) + return push(Query.order_asc(attribute)) + end + + def order_desc(attribute) + return push(Query.order_desc(attribute)) + end + + def order_random() + return push(Query.order_random()) + end + + def limit(limit) + return push(Query.limit(limit)) + end + + def offset(offset) + return push(Query.offset(offset)) + end + + def contains(attribute, value) + return push(Query.contains(attribute, value)) + end + + def contains_any(attribute, value) + return push(Query.contains_any(attribute, value)) + end + + def contains_all(attribute, value) + return push(Query.contains_all(attribute, value)) + end + + def not_contains(attribute, value) + return push(Query.not_contains(attribute, value)) + end + + def not_search(attribute, value) + return push(Query.not_search(attribute, value)) + end + + def not_between(attribute, start, ending) + return push(Query.not_between(attribute, start, ending)) + end + + def not_starts_with(attribute, value) + return push(Query.not_starts_with(attribute, value)) + end + + def not_ends_with(attribute, value) + return push(Query.not_ends_with(attribute, value)) + end + + def regex(attribute, pattern) + return push(Query.regex(attribute, pattern)) + end + + def exists(attributes) + return push(Query.exists(attributes)) + end + + def not_exists(attributes) + return push(Query.not_exists(attributes)) + end + + def created_before(value) + return push(Query.created_before(value)) + end + + def created_after(value) + return push(Query.created_after(value)) + end + + def created_between(start, ending) + return push(Query.created_between(start, ending)) + end + + def updated_before(value) + return push(Query.updated_before(value)) + end + + def updated_after(value) + return push(Query.updated_after(value)) + end + + def updated_between(start, ending) + return push(Query.updated_between(start, ending)) + end + + def or(queries) + return push(Query.or(queries)) + end + + def and(queries) + return push(Query.and(queries)) + end + + def elem_match(attribute, queries) + return push(Query.elem_match(attribute, queries)) + end + + def relationship(attribute, queries) + return push(Query.relationship(attribute, queries)) + end + + def distance_equal(attribute, values, distance, meters = true) + return push(Query.distance_equal(attribute, values, distance, meters)) + end + + def distance_not_equal(attribute, values, distance, meters = true) + return push(Query.distance_not_equal(attribute, values, distance, meters)) + end + + def distance_greater_than(attribute, values, distance, meters = true) + return push(Query.distance_greater_than(attribute, values, distance, meters)) + end + + def distance_less_than(attribute, values, distance, meters = true) + return push(Query.distance_less_than(attribute, values, distance, meters)) + end + + def intersects(attribute, values) + return push(Query.intersects(attribute, values)) + end + + def not_intersects(attribute, values) + return push(Query.not_intersects(attribute, values)) + end + + def crosses(attribute, values) + return push(Query.crosses(attribute, values)) + end + + def not_crosses(attribute, values) + return push(Query.not_crosses(attribute, values)) + end + + def overlaps(attribute, values) + return push(Query.overlaps(attribute, values)) + end + + def not_overlaps(attribute, values) + return push(Query.not_overlaps(attribute, values)) + end + + def touches(attribute, values) + return push(Query.touches(attribute, values)) + end + + def not_touches(attribute, values) + return push(Query.not_touches(attribute, values)) + end + + def count(attribute = '*', alias_name = '') + return push(Query.count(attribute, alias_name)) + end + + def count_distinct(attribute, alias_name = '') + return push(Query.count_distinct(attribute, alias_name)) + end + + def sum(attribute, alias_name = '') + return push(Query.sum(attribute, alias_name)) + end + + def avg(attribute, alias_name = '') + return push(Query.avg(attribute, alias_name)) + end + + def min(attribute, alias_name = '') + return push(Query.min(attribute, alias_name)) + end + + def max(attribute, alias_name = '') + return push(Query.max(attribute, alias_name)) + end + + def stddev(attribute, alias_name = '') + return push(Query.stddev(attribute, alias_name)) + end + + def stddev_pop(attribute, alias_name = '') + return push(Query.stddev_pop(attribute, alias_name)) + end + + def stddev_samp(attribute, alias_name = '') + return push(Query.stddev_samp(attribute, alias_name)) + end + + def variance(attribute, alias_name = '') + return push(Query.variance(attribute, alias_name)) + end + + def var_pop(attribute, alias_name = '') + return push(Query.var_pop(attribute, alias_name)) + end + + def var_samp(attribute, alias_name = '') + return push(Query.var_samp(attribute, alias_name)) + end + + def bit_and(attribute, alias_name = '') + return push(Query.bit_and(attribute, alias_name)) + end + + def bit_or(attribute, alias_name = '') + return push(Query.bit_or(attribute, alias_name)) + end + + def bit_xor(attribute, alias_name = '') + return push(Query.bit_xor(attribute, alias_name)) + end + + def group_by(attributes) + return push(Query.group_by(attributes)) + end + + def having(queries) + return push(Query.having(queries)) + end + + def distinct() + return push(Query.distinct()) + end + + def join(table, left, right = '', operator = '=', alias_name = '') + return push(Query.join(table, left, right, operator, alias_name)) + end + + def left_join(table, left, right = '', operator = '=', alias_name = '') + return push(Query.left_join(table, left, right, operator, alias_name)) + end + + def right_join(table, left, right = '', operator = '=', alias_name = '') + return push(Query.right_join(table, left, right, operator, alias_name)) + end + + def full_outer_join(table, left, right = '', operator = '=', alias_name = '') + return push(Query.full_outer_join(table, left, right, operator, alias_name)) + end + + def cross_join(table, alias_name = '') + return push(Query.cross_join(table, alias_name)) + end + + def vector_dot(attribute, vector) + return push(Query.vector_dot(attribute, vector)) + end + + def vector_cosine(attribute, vector) + return push(Query.vector_cosine(attribute, vector)) + end + + def vector_euclidean(attribute, vector) + return push(Query.vector_euclidean(attribute, vector)) + end + + def covers(attribute, values) + return push(Query.covers(attribute, values)) + end + + def not_covers(attribute, values) + return push(Query.not_covers(attribute, values)) + end + + def spatial_equals(attribute, values) + return push(Query.spatial_equals(attribute, values)) + end + + def not_spatial_equals(attribute, values) + return push(Query.not_spatial_equals(attribute, values)) + end + + def page(page, per_page = 25) + return push(Query.page(page, per_page)) + end + + private + + def push(query) + if query.is_a?(Array) + @queries.concat(query) + else + @queries << query + end + + return self + end + end +end diff --git a/lib/appwrite/services/account.rb b/lib/appwrite/services/account.rb index 837b7cb8..2e21f2a1 100644 --- a/lib/appwrite/services/account.rb +++ b/lib/appwrite/services/account.rb @@ -49,8 +49,6 @@ def create( password:, name: nil ) - api_path = '/account' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -63,6 +61,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account' + api_params = { userId: user_id, email: email, @@ -126,13 +126,13 @@ def list_consents( def get_consent( consent_id: ) - api_path = '/account/consents/{consentId}' - .gsub('{consentId}', consent_id) - - if consent_id.nil? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end + api_path = '/account/consents/{consentId}' + .gsub('{consentId}', consent_id) + api_params = {} api_headers = { @@ -159,13 +159,13 @@ def get_consent( def delete_consent( consent_id: ) - api_path = '/account/consents/{consentId}' - .gsub('{consentId}', consent_id) - - if consent_id.nil? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end + api_path = '/account/consents/{consentId}' + .gsub('{consentId}', consent_id) + api_params = {} api_headers = { @@ -196,13 +196,13 @@ def list_consent_tokens( queries: nil, total: nil ) - api_path = '/account/consents/{consentId}/tokens' - .gsub('{consentId}', consent_id) - - if consent_id.nil? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end + api_path = '/account/consents/{consentId}/tokens' + .gsub('{consentId}', consent_id) + api_params = { queries: queries, total: total, @@ -233,18 +233,18 @@ 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? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/account/consents/{consentId}/tokens/{tokenId}' + .gsub('{consentId}', consent_id) + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { @@ -273,18 +273,18 @@ 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? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/account/consents/{consentId}/tokens/{tokenId}' + .gsub('{consentId}', consent_id) + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { @@ -318,8 +318,6 @@ def update_email( email:, password: ) - api_path = '/account/email' - if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end @@ -328,6 +326,8 @@ def update_email( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/email' + api_params = { email: email, password: password, @@ -387,57 +387,26 @@ def list_identities( def delete_identity( identity_id: ) - api_path = '/account/identities/{identityId}' - .gsub('{identityId}', identity_id) - - if identity_id.nil? + if identity_id.nil? || identity_id == '' raise Appwrite::Exception.new('Missing required parameter: "identityId"') end + api_path = '/account/identities/{identityId}' + .gsub('{identityId}', identity_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', - } - - @client.call( - method: 'DELETE', - path: api_path, - headers: api_headers, - params: api_params, - ) - end - - # Get the list of latest security activity logs for the currently logged in - # user. Each log returns user IP address, location and date and time of log. - # - # @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). Only supported methods are limit and offset - # @param [] total When set to false, the total count returned will be 0 and will not be calculated. - # - # @return [LogList] - def list_logs( - queries: nil, - total: nil - ) - api_path = '/account/logs' - - api_params = { - queries: queries, - total: total, - } - - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( - method: 'GET', + method: 'DELETE', path: api_path, headers: api_headers, params: api_params, - response_type: Models::LogList ) end @@ -449,12 +418,12 @@ def list_logs( def update_mfa( mfa: ) - api_path = '/account/mfa' - if mfa.nil? raise Appwrite::Exception.new('Missing required parameter: "mfa"') end + api_path = '/account/mfa' + api_params = { mfa: mfa, } @@ -485,13 +454,13 @@ def update_mfa( def create_mfa_authenticator( type: ) - api_path = '/account/mfa/authenticators/{type}' - .gsub('{type}', type) - if type.nil? raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/account/mfa/authenticators/{type}' + .gsub('{type}', type) + api_params = {} api_headers = { @@ -521,9 +490,6 @@ def update_mfa_authenticator( type:, otp: ) - api_path = '/account/mfa/authenticators/{type}' - .gsub('{type}', type) - if type.nil? raise Appwrite::Exception.new('Missing required parameter: "type"') end @@ -532,6 +498,9 @@ def update_mfa_authenticator( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/account/mfa/authenticators/{type}' + .gsub('{type}', type) + api_params = { otp: otp, } @@ -559,18 +528,19 @@ def update_mfa_authenticator( def delete_mfa_authenticator( type: ) - api_path = '/account/mfa/authenticators/{type}' - .gsub('{type}', type) - if type.nil? raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/account/mfa/authenticators/{type}' + .gsub('{type}', type) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -591,12 +561,12 @@ def delete_mfa_authenticator( def create_mfa_challenge( factor: ) - api_path = '/account/mfa/challenges' - if factor.nil? raise Appwrite::Exception.new('Missing required parameter: "factor"') end + api_path = '/account/mfa/challenges' + api_params = { factor: factor, } @@ -630,8 +600,6 @@ def update_mfa_challenge( challenge_id:, otp: ) - api_path = '/account/mfa/challenges' - if challenge_id.nil? raise Appwrite::Exception.new('Missing required parameter: "challengeId"') end @@ -640,6 +608,8 @@ def update_mfa_challenge( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/account/mfa/challenges' + api_params = { challengeId: challenge_id, otp: otp, @@ -772,12 +742,12 @@ def update_mfa_recovery_codes() def update_name( name: ) - api_path = '/account/name' - if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/account/name' + api_params = { name: name, } @@ -1029,12 +999,12 @@ def update_password( password:, old_password: nil ) - api_path = '/account/password' - if password.nil? raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/password' + api_params = { password: password, oldPassword: old_password, @@ -1069,8 +1039,6 @@ def update_phone( phone:, password: ) - api_path = '/account/phone' - if phone.nil? raise Appwrite::Exception.new('Missing required parameter: "phone"') end @@ -1079,6 +1047,8 @@ def update_phone( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/phone' + api_params = { phone: phone, password: password, @@ -1132,12 +1102,12 @@ def get_prefs() def update_prefs( prefs: ) - api_path = '/account/prefs' - if prefs.nil? raise Appwrite::Exception.new('Missing required parameter: "prefs"') end + api_path = '/account/prefs' + api_params = { prefs: prefs, } @@ -1174,8 +1144,6 @@ def create_recovery( email:, url: ) - api_path = '/account/recovery' - if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end @@ -1184,6 +1152,8 @@ def create_recovery( raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/account/recovery' + api_params = { email: email, url: url, @@ -1225,8 +1195,6 @@ def update_recovery( secret:, password: ) - api_path = '/account/recovery' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1239,6 +1207,8 @@ def update_recovery( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/recovery' + api_params = { userId: user_id, secret: secret, @@ -1392,7 +1362,8 @@ def list_sessions( end # Delete all sessions from the user account and remove any sessions cookies - # from the end client. + # from the end client. Pass `current` as false to keep the session making the + # request and sign out of every other session. # # @param [] current Delete the current session too. Use false to sign out of every other session while staying signed in on this one. # @@ -1409,6 +1380,7 @@ def delete_sessions( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1451,6 +1423,9 @@ def create_anonymous_session() # Allow the user to login into their account by providing a valid email and # password combination. This route will create a new session for the user. + # Use the optional `duration` parameter to create a shorter session, for + # example when the user doesn't choose "remember me". It must be at least 60 + # seconds and cannot exceed the project maximum session length. # # A user is limited to 10 active sessions at a time by default. [Learn more # about session @@ -1466,8 +1441,6 @@ def create_email_password_session( password:, duration: nil ) - api_path = '/account/sessions/email' - if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end @@ -1476,6 +1449,8 @@ def create_email_password_session( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/sessions/email' + api_params = { email: email, password: password, @@ -1605,8 +1580,6 @@ def update_magic_url_session( user_id:, secret: ) - api_path = '/account/sessions/magic-url' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1615,6 +1588,8 @@ def update_magic_url_session( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/sessions/magic-url' + api_params = { userId: user_id, secret: secret, @@ -1650,8 +1625,6 @@ def update_phone_session( user_id:, secret: ) - api_path = '/account/sessions/phone' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1660,6 +1633,8 @@ def update_phone_session( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/sessions/phone' + api_params = { userId: user_id, secret: secret, @@ -1692,8 +1667,6 @@ def create_session( user_id:, secret: ) - api_path = '/account/sessions/token' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1702,6 +1675,8 @@ def create_session( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/sessions/token' + api_params = { userId: user_id, secret: secret, @@ -1731,13 +1706,13 @@ def create_session( def get_session( session_id: ) - api_path = '/account/sessions/{sessionId}' - .gsub('{sessionId}', session_id) - - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/account/sessions/{sessionId}' + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { @@ -1764,13 +1739,13 @@ def get_session( def update_session( session_id: ) - api_path = '/account/sessions/{sessionId}' - .gsub('{sessionId}', session_id) - - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/account/sessions/{sessionId}' + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { @@ -1800,18 +1775,19 @@ def update_session( def delete_session( session_id: ) - api_path = '/account/sessions/{sessionId}' - .gsub('{sessionId}', session_id) - - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/account/sessions/{sessionId}' + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1873,8 +1849,6 @@ def create_email_token( email:, phrase: nil ) - api_path = '/account/tokens/email' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1883,6 +1857,8 @@ def create_email_token( raise Appwrite::Exception.new('Missing required parameter: "email"') end + api_path = '/account/tokens/email' + api_params = { userId: user_id, email: email, @@ -1931,8 +1907,6 @@ def create_magic_url_token( url: nil, phrase: nil ) - api_path = '/account/tokens/magic-url' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1941,6 +1915,8 @@ def create_magic_url_token( raise Appwrite::Exception.new('Missing required parameter: "email"') end + api_path = '/account/tokens/magic-url' + api_params = { userId: user_id, email: email, @@ -1974,11 +1950,15 @@ def create_magic_url_token( # session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) # endpoint. # + # If there is already an active session, the OAuth2 identity is attached to + # the logged-in account and that session stays active until the token is + # exchanged for a new one. + # # A user is limited to 10 active sessions at a time by default. [Learn more # about session # limits](https://appwrite.io/docs/authentication-security#limits). # - # @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + # @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom. # @param [String] success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. # @param [String] failure URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. # @param [Array] scopes A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. @@ -1992,13 +1972,13 @@ def create_o_auth2_token( scopes: nil, state: nil ) - api_path = '/account/tokens/oauth2/{provider}' - .gsub('{provider}', provider) - if provider.nil? raise Appwrite::Exception.new('Missing required parameter: "provider"') end + api_path = '/account/tokens/oauth2/{provider}' + .gsub('{provider}', provider) + api_params = { success: success, failure: failure, @@ -2117,8 +2097,6 @@ def create_phone_token( user_id:, phone: ) - api_path = '/account/tokens/phone' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2127,6 +2105,8 @@ def create_phone_token( raise Appwrite::Exception.new('Missing required parameter: "phone"') end + api_path = '/account/tokens/phone' + api_params = { userId: user_id, phone: phone, @@ -2169,12 +2149,12 @@ def create_phone_token( def create_email_verification( url: ) - api_path = '/account/verifications/email' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/account/verifications/email' + api_params = { url: url, } @@ -2219,12 +2199,12 @@ def create_email_verification( def create_verification( url: ) - api_path = '/account/verifications/email' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/account/verifications/email' + api_params = { url: url, } @@ -2257,8 +2237,6 @@ def update_email_verification( user_id:, secret: ) - api_path = '/account/verifications/email' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2267,6 +2245,8 @@ def update_email_verification( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/verifications/email' + api_params = { userId: user_id, secret: secret, @@ -2303,8 +2283,6 @@ def update_verification( user_id:, secret: ) - api_path = '/account/verifications/email' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2313,6 +2291,8 @@ def update_verification( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/verifications/email' + api_params = { userId: user_id, secret: secret, @@ -2465,8 +2445,6 @@ def update_phone_verification( user_id:, secret: ) - api_path = '/account/verifications/phone' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2475,6 +2453,8 @@ def update_phone_verification( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/verifications/phone' + api_params = { userId: user_id, secret: secret, diff --git a/lib/appwrite/services/activities.rb b/lib/appwrite/services/activities.rb index 2c4c457f..e6030e18 100644 --- a/lib/appwrite/services/activities.rb +++ b/lib/appwrite/services/activities.rb @@ -43,13 +43,13 @@ def list_events( def get_event( event_id: ) - api_path = '/activities/events/{eventId}' - .gsub('{eventId}', event_id) - - if event_id.nil? + if event_id.nil? || event_id == '' raise Appwrite::Exception.new('Missing required parameter: "eventId"') end + api_path = '/activities/events/{eventId}' + .gsub('{eventId}', event_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/advisor.rb b/lib/appwrite/services/advisor.rb index 7efe9fa7..180fb950 100644 --- a/lib/appwrite/services/advisor.rb +++ b/lib/appwrite/services/advisor.rb @@ -49,13 +49,13 @@ def list_reports( def get_report( report_id: ) - api_path = '/reports/{reportId}' - .gsub('{reportId}', report_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end + api_path = '/reports/{reportId}' + .gsub('{reportId}', report_id) + api_params = {} api_headers = { @@ -82,18 +82,19 @@ def get_report( def delete_report( report_id: ) - api_path = '/reports/{reportId}' - .gsub('{reportId}', report_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end + api_path = '/reports/{reportId}' + .gsub('{reportId}', report_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -118,13 +119,13 @@ def list_insights( queries: nil, total: nil ) - api_path = '/reports/{reportId}/insights' - .gsub('{reportId}', report_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end + api_path = '/reports/{reportId}/insights' + .gsub('{reportId}', report_id) + api_params = { queries: queries, total: total, @@ -155,18 +156,18 @@ def get_insight( report_id:, insight_id: ) - api_path = '/reports/{reportId}/insights/{insightId}' - .gsub('{reportId}', report_id) - .gsub('{insightId}', insight_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end - if insight_id.nil? + if insight_id.nil? || insight_id == '' raise Appwrite::Exception.new('Missing required parameter: "insightId"') end + api_path = '/reports/{reportId}/insights/{insightId}' + .gsub('{reportId}', report_id) + .gsub('{insightId}', insight_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/apps.rb b/lib/appwrite/services/apps.rb index c4c15c1f..ceeb7dca 100644 --- a/lib/appwrite/services/apps.rb +++ b/lib/appwrite/services/apps.rb @@ -81,8 +81,6 @@ def create( device_flow: nil, team_id: nil ) - api_path = '/apps' - if app_id.nil? raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -95,6 +93,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "redirectUris"') end + api_path = '/apps' + api_params = { appId: app_id, name: name, @@ -186,13 +186,13 @@ def list_o_auth2_scopes() def get( app_id: ) - api_path = '/apps/{appId}' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -255,10 +255,7 @@ def update( installation_scopes: nil, installation_redirect_url: nil ) - api_path = '/apps/{appId}' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -266,6 +263,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/apps/{appId}' + .gsub('{appId}', app_id) + api_params = { name: name, description: description, @@ -311,13 +311,13 @@ def update( def delete( app_id: ) - api_path = '/apps/{appId}' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -348,13 +348,13 @@ def list_installations( queries: nil, total: nil ) - api_path = '/apps/{appId}/installations' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/installations' + .gsub('{appId}', app_id) + api_params = { queries: queries, total: total, @@ -386,18 +386,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/apps/{appId}/installations/{installationId}' + .gsub('{appId}', app_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -426,18 +426,18 @@ def delete_installation( app_id:, installation_id: ) - api_path = '/apps/{appId}/installations/{installationId}' - .gsub('{appId}', app_id) - .gsub('{installationId}', installation_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/apps/{appId}/installations/{installationId}' + .gsub('{appId}', app_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -471,18 +471,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/apps/{appId}/installations/{installationId}/tokens' + .gsub('{appId}', app_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -512,13 +512,13 @@ def list_keys( queries: nil, total: nil ) - api_path = '/apps/{appId}/keys' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/keys' + .gsub('{appId}', app_id) + api_params = { queries: queries, total: total, @@ -548,13 +548,13 @@ def list_keys( def create_key( app_id: ) - api_path = '/apps/{appId}/keys' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/keys' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -582,18 +582,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/apps/{appId}/keys/{keyId}' + .gsub('{appId}', app_id) + .gsub('{keyId}', key_id) + api_params = {} api_headers = { @@ -620,18 +620,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/apps/{appId}/keys/{keyId}' + .gsub('{appId}', app_id) + .gsub('{keyId}', key_id) + api_params = {} api_headers = { @@ -653,17 +653,14 @@ def delete_key( # 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. + # @param [Array] labels Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. Reserved labels are rejected. # # @return [App] def update_labels( app_id:, labels: ) - api_path = '/apps/{appId}/labels' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -671,6 +668,9 @@ def update_labels( raise Appwrite::Exception.new('Missing required parameter: "labels"') end + api_path = '/apps/{appId}/labels' + .gsub('{appId}', app_id) + api_params = { labels: labels, } @@ -702,13 +702,13 @@ def list_secrets( queries: nil, total: nil ) - api_path = '/apps/{appId}/secrets' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/secrets' + .gsub('{appId}', app_id) + api_params = { queries: queries, total: total, @@ -736,13 +736,13 @@ def list_secrets( def create_secret( app_id: ) - api_path = '/apps/{appId}/secrets' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/secrets' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -770,18 +770,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if secret_id.nil? + if secret_id.nil? || secret_id == '' raise Appwrite::Exception.new('Missing required parameter: "secretId"') end + api_path = '/apps/{appId}/secrets/{secretId}' + .gsub('{appId}', app_id) + .gsub('{secretId}', secret_id) + api_params = {} api_headers = { @@ -808,18 +808,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if secret_id.nil? + if secret_id.nil? || secret_id == '' raise Appwrite::Exception.new('Missing required parameter: "secretId"') end + api_path = '/apps/{appId}/secrets/{secretId}' + .gsub('{appId}', app_id) + .gsub('{secretId}', secret_id) + api_params = {} api_headers = { @@ -846,10 +846,7 @@ def update_team( app_id:, team_id: ) - api_path = '/apps/{appId}/team' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -857,6 +854,9 @@ def update_team( raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/apps/{appId}/team' + .gsub('{appId}', app_id) + api_params = { teamId: team_id, } @@ -884,13 +884,13 @@ def update_team( def delete_tokens( app_id: ) - api_path = '/apps/{appId}/tokens' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/tokens' + .gsub('{appId}', app_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/avatars.rb b/lib/appwrite/services/avatars.rb index d3ab6a03..1555c4f2 100644 --- a/lib/appwrite/services/avatars.rb +++ b/lib/appwrite/services/avatars.rb @@ -29,13 +29,13 @@ def get_browser( height: nil, quality: nil ) - api_path = '/avatars/browsers/{code}' - .gsub('{code}', code) - if code.nil? raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/avatars/browsers/{code}' + .gsub('{code}', code) + api_params = { width: width, height: height, @@ -77,13 +77,13 @@ def get_credit_card( height: nil, quality: nil ) - api_path = '/avatars/credit-cards/{code}' - .gsub('{code}', code) - if code.nil? raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/avatars/credit-cards/{code}' + .gsub('{code}', code) + api_params = { width: width, height: height, @@ -114,12 +114,12 @@ def get_credit_card( def get_favicon( url: ) - api_path = '/avatars/favicon' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/avatars/favicon' + api_params = { url: url, } @@ -160,13 +160,13 @@ def get_flag( height: nil, quality: nil ) - api_path = '/avatars/flags/{code}' - .gsub('{code}', code) - if code.nil? raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/avatars/flags/{code}' + .gsub('{code}', code) + api_params = { width: width, height: height, @@ -208,12 +208,12 @@ def get_image( width: nil, height: nil ) - api_path = '/avatars/image' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/avatars/image' + api_params = { url: url, width: width, @@ -285,9 +285,9 @@ def get_initials( end # Returns the best available profile photo for a user. The endpoint tries - # each source in priority order and returns the first successful result: - # OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in - # static fallback. + # each source in priority order and returns the first successful result: a + # custom uploaded photo (see avatars.updatePhoto), OAuth2 identity photo, + # Gravatar, Libravatar, Appwrite Initials, built-in static fallback. # # Passing `userId` — `current()` for the authenticated user — resolves # the photo from everything known about that user: identity photos, email, @@ -433,12 +433,12 @@ def get_qr( margin: nil, download: nil ) - api_path = '/avatars/qr' - if text.nil? raise Appwrite::Exception.new('Missing required parameter: "text"') end + api_path = '/avatars/qr' + api_params = { text: text, size: size, @@ -471,7 +471,7 @@ def get_qr( # dimensions are not specified, the default viewport size is 1280x720px. # # @param [String] url Website URL which you want to capture. - # @param [Hash] headers HTTP headers to send with the browser request. Defaults to empty. + # @param [Hash] headers HTTP headers to send with the browser request. Only Accept and Accept-Language are allowed. Defaults to empty. # @param [Integer] viewport_width Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. # @param [Integer] viewport_height Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720. # @param [Float] scale Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1. @@ -514,12 +514,12 @@ def get_screenshot( quality: nil, output: nil ) - api_path = '/avatars/screenshots' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/avatars/screenshots' + api_params = { url: url, headers: headers, diff --git a/lib/appwrite/services/backups.rb b/lib/appwrite/services/backups.rb index f74a5917..9d58c7bf 100644 --- a/lib/appwrite/services/backups.rb +++ b/lib/appwrite/services/backups.rb @@ -44,12 +44,12 @@ def create_archive( services:, resource_id: nil ) - api_path = '/backups/archives' - if services.nil? raise Appwrite::Exception.new('Missing required parameter: "services"') end + api_path = '/backups/archives' + api_params = { services: services, resourceId: resource_id, @@ -78,13 +78,13 @@ def create_archive( def get_archive( archive_id: ) - api_path = '/backups/archives/{archiveId}' - .gsub('{archiveId}', archive_id) - - if archive_id.nil? + if archive_id.nil? || archive_id == '' raise Appwrite::Exception.new('Missing required parameter: "archiveId"') end + api_path = '/backups/archives/{archiveId}' + .gsub('{archiveId}', archive_id) + api_params = {} api_headers = { @@ -109,13 +109,13 @@ def get_archive( def delete_archive( archive_id: ) - api_path = '/backups/archives/{archiveId}' - .gsub('{archiveId}', archive_id) - - if archive_id.nil? + if archive_id.nil? || archive_id == '' raise Appwrite::Exception.new('Missing required parameter: "archiveId"') end + api_path = '/backups/archives/{archiveId}' + .gsub('{archiveId}', archive_id) + api_params = {} api_headers = { @@ -180,8 +180,6 @@ def create_policy( resource_id: nil, enabled: nil ) - api_path = '/backups/policies' - if policy_id.nil? raise Appwrite::Exception.new('Missing required parameter: "policyId"') end @@ -198,6 +196,8 @@ def create_policy( raise Appwrite::Exception.new('Missing required parameter: "schedule"') end + api_path = '/backups/policies' + api_params = { policyId: policy_id, name: name, @@ -231,13 +231,13 @@ def create_policy( def get_policy( policy_id: ) - api_path = '/backups/policies/{policyId}' - .gsub('{policyId}', policy_id) - - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/backups/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -270,13 +270,13 @@ def update_policy( schedule: nil, enabled: nil ) - api_path = '/backups/policies/{policyId}' - .gsub('{policyId}', policy_id) - - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/backups/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = { name: name, retention: retention, @@ -307,13 +307,13 @@ def update_policy( def delete_policy( policy_id: ) - api_path = '/backups/policies/{policyId}' - .gsub('{policyId}', policy_id) - - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/backups/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -375,8 +375,6 @@ def create_restoration( new_resource_id: nil, new_resource_name: nil ) - api_path = '/backups/restoration' - if archive_id.nil? raise Appwrite::Exception.new('Missing required parameter: "archiveId"') end @@ -385,6 +383,8 @@ def create_restoration( raise Appwrite::Exception.new('Missing required parameter: "services"') end + api_path = '/backups/restoration' + api_params = { archiveId: archive_id, services: services, @@ -443,13 +443,13 @@ def list_restorations( def get_restoration( restoration_id: ) - api_path = '/backups/restorations/{restorationId}' - .gsub('{restorationId}', restoration_id) - - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/backups/restorations/{restorationId}' + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/databases.rb b/lib/appwrite/services/databases.rb index c8783184..46bb76c1 100644 --- a/lib/appwrite/services/databases.rb +++ b/lib/appwrite/services/databases.rb @@ -60,8 +60,6 @@ def create( name:, enabled: nil ) - api_path = '/databases' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -70,6 +68,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/databases' + api_params = { databaseId: database_id, name: name, @@ -168,13 +168,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/databases/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -206,13 +206,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/databases/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -244,18 +244,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/databases/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -279,13 +280,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/databases/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -317,13 +318,13 @@ def create_operations( def get( database_id: ) - api_path = '/databases/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -355,13 +356,13 @@ def update( name: nil, enabled: nil ) - api_path = '/databases/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -394,18 +395,19 @@ def update( def delete( database_id: ) - api_path = '/databases/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -434,13 +436,13 @@ def list_collections( search: nil, total: nil ) - api_path = '/databases/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -476,7 +478,7 @@ def list_collections( # @param [] document_security Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] enabled Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. # @param [Array] attributes Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. - # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). # # @return [Collection] def create_collection( @@ -489,10 +491,7 @@ def create_collection( attributes: nil, indexes: nil ) - api_path = '/databases/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -504,6 +503,9 @@ def create_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/databases/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { collectionId: collection_id, name: name, @@ -543,18 +545,18 @@ def get_collection( database_id:, collection_id: ) - api_path = '/databases/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { @@ -594,18 +596,18 @@ def update_collection( enabled: nil, purge: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { name: name, permissions: permissions, @@ -643,23 +645,24 @@ def delete_collection( database_id:, collection_id: ) - api_path = '/databases/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -687,18 +690,18 @@ def list_attributes( queries: nil, total: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -745,15 +748,11 @@ def create_big_int_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -765,6 +764,10 @@ def create_big_int_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -816,20 +819,15 @@ def update_big_int_attribute( max: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -841,6 +839,11 @@ def update_big_int_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -886,15 +889,11 @@ def create_boolean_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -906,6 +905,10 @@ def create_boolean_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -950,20 +953,15 @@ def update_boolean_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -975,6 +973,11 @@ def update_boolean_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1017,15 +1020,11 @@ def create_datetime_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1037,6 +1036,10 @@ def create_datetime_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1081,20 +1084,15 @@ def update_datetime_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1106,6 +1104,11 @@ def update_datetime_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1149,15 +1152,11 @@ def create_email_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1169,6 +1168,10 @@ def create_email_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1214,20 +1217,15 @@ def update_email_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1239,6 +1237,11 @@ def update_email_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1285,15 +1288,11 @@ def create_enum_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1309,6 +1308,10 @@ def create_enum_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, elements: elements, @@ -1357,20 +1360,15 @@ def update_enum_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1386,6 +1384,11 @@ def update_enum_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { elements: elements, required: required, @@ -1435,15 +1438,11 @@ def create_float_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1455,6 +1454,10 @@ def create_float_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1506,20 +1509,15 @@ def update_float_attribute( max: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1531,6 +1529,11 @@ def update_float_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1581,15 +1584,11 @@ def create_integer_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1601,6 +1600,10 @@ def create_integer_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1652,20 +1655,15 @@ def update_integer_attribute( max: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1677,6 +1675,11 @@ def update_integer_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1722,15 +1725,11 @@ def create_ip_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1742,6 +1741,10 @@ def create_ip_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1787,20 +1790,15 @@ def update_ip_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1812,6 +1810,11 @@ def update_ip_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1852,15 +1855,11 @@ def create_line_attribute( required:, default: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1872,6 +1871,10 @@ def create_line_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1915,20 +1918,15 @@ def update_line_attribute( default: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1936,6 +1934,11 @@ def update_line_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1981,15 +1984,11 @@ def create_longtext_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2001,6 +2000,10 @@ def create_longtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2047,20 +2050,15 @@ def update_longtext_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2072,6 +2070,11 @@ def update_longtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2117,15 +2120,11 @@ def create_mediumtext_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2137,6 +2136,10 @@ def create_mediumtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2183,20 +2186,15 @@ def update_mediumtext_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2208,6 +2206,11 @@ def update_mediumtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2248,15 +2251,11 @@ def create_point_attribute( required:, default: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2268,6 +2267,10 @@ def create_point_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2311,20 +2314,15 @@ def update_point_attribute( default: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2332,6 +2330,11 @@ def update_point_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2372,15 +2375,11 @@ def create_polygon_attribute( required:, default: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2392,6 +2391,10 @@ def create_polygon_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2435,20 +2438,15 @@ def update_polygon_attribute( default: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2456,6 +2454,11 @@ def update_polygon_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2504,15 +2507,11 @@ def create_relationship_attribute( two_way_key: nil, on_delete: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2524,6 +2523,10 @@ def create_relationship_attribute( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { relatedCollectionId: related_collection_id, type: type, @@ -2569,23 +2572,23 @@ def update_relationship_attribute( on_delete: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { onDelete: on_delete, newKey: new_key, @@ -2632,15 +2635,11 @@ def create_string_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2656,6 +2655,10 @@ def create_string_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, size: size, @@ -2705,20 +2708,15 @@ def update_string_attribute( size: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2730,6 +2728,11 @@ def update_string_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2776,15 +2779,11 @@ def create_text_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2796,6 +2795,10 @@ def create_text_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2842,20 +2845,15 @@ def update_text_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2867,6 +2865,11 @@ def update_text_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2910,15 +2913,11 @@ def create_url_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2930,6 +2929,10 @@ def create_url_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2975,20 +2978,15 @@ def update_url_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3000,6 +2998,11 @@ def update_url_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3047,15 +3050,11 @@ def create_varchar_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3071,6 +3070,10 @@ def create_varchar_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, size: size, @@ -3120,20 +3123,15 @@ def update_varchar_attribute( size: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3145,6 +3143,11 @@ def update_varchar_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3176,29 +3179,29 @@ def update_varchar_attribute( # @param [String] collection_id Collection ID. # @param [String] key Attribute Key. # - # @return [AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributeString] + # @return [AttributeBoolean, AttributeBigint, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributePoint, AttributeLine, AttributePolygon, AttributeVarchar, AttributeText, AttributeMediumtext, AttributeLongtext, AttributeString] def get_attribute( database_id:, collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -3242,6 +3245,11 @@ def get_attribute( return Models::AttributeBoolean.from(map: response) end + if response['type'] == 'bigint' + + return Models::AttributeBigint.from(map: response) + end + if response['type'] == 'integer' return Models::AttributeInteger.from(map: response) @@ -3262,6 +3270,41 @@ def get_attribute( return Models::AttributeRelationship.from(map: response) end + if response['type'] == 'point' + + return Models::AttributePoint.from(map: response) + end + + if response['type'] == 'linestring' + + return Models::AttributeLine.from(map: response) + end + + if response['type'] == 'polygon' + + return Models::AttributePolygon.from(map: response) + end + + if response['type'] == 'varchar' + + return Models::AttributeVarchar.from(map: response) + end + + if response['type'] == 'text' + + return Models::AttributeText.from(map: response) + end + + if response['type'] == 'mediumtext' + + return Models::AttributeMediumtext.from(map: response) + end + + if response['type'] == 'longtext' + + return Models::AttributeLongtext.from(map: response) + end + if response['type'] == 'string' return Models::AttributeString.from(map: response) @@ -3285,28 +3328,29 @@ def delete_attribute( collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3339,18 +3383,18 @@ def list_documents( total: nil, ttl: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3396,15 +3440,11 @@ def create_document( permissions: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3416,6 +3456,10 @@ def create_document( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documentId: document_id, data: data, @@ -3458,15 +3502,11 @@ def create_documents( documents:, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3474,6 +3514,10 @@ def create_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -3515,15 +3559,11 @@ def upsert_documents( documents:, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3531,6 +3571,10 @@ def upsert_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -3572,18 +3616,18 @@ def update_documents( queries: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { data: data, queries: queries, @@ -3623,18 +3667,18 @@ def delete_documents( queries: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3675,23 +3719,23 @@ def get_document( queries: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3735,23 +3779,23 @@ def upsert_document( permissions: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -3795,23 +3839,23 @@ def update_document( permissions: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -3850,23 +3894,23 @@ def delete_document( document_id:, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { transactionId: transaction_id, } @@ -3874,6 +3918,7 @@ def delete_document( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3907,28 +3952,28 @@ def decrement_document_attribute( min: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, min: min, @@ -3973,28 +4018,28 @@ def increment_document_attribute( max: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, max: max, @@ -4033,18 +4078,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -4069,7 +4114,9 @@ def list_indexes( # # Creates an index on the attributes listed. Your index should include all # the attributes you will query in a single request. - # Attributes can be `key`, `fulltext`, and `unique`. + # Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. + # `trigram` is only available on PostgreSQL and lets `contains`, + # `startsWith`, and `endsWith` queries on string attributes use an index. # # @param [String] database_id Database ID. # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4089,15 +4136,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -4113,6 +4156,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "attributes"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, type: type, @@ -4151,23 +4198,23 @@ def get_index( collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -4199,28 +4246,29 @@ def delete_index( collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/documents_db.rb b/lib/appwrite/services/documents_db.rb index f97888a7..efa8021e 100644 --- a/lib/appwrite/services/documents_db.rb +++ b/lib/appwrite/services/documents_db.rb @@ -57,8 +57,6 @@ def create( replicas: nil, sync_mode: nil ) - api_path = '/documentsdb' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -67,6 +65,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb' + api_params = { databaseId: database_id, name: name, @@ -92,8 +92,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -184,13 +184,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/documentsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/documentsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -254,18 +254,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/documentsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -286,13 +287,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/documentsdb/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -321,13 +322,13 @@ def create_operations( def get( database_id: ) - api_path = '/documentsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -362,10 +363,7 @@ def update( replicas: nil, sync_mode: nil ) - api_path = '/documentsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -373,6 +371,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -405,18 +406,19 @@ def update( def delete( database_id: ) - api_path = '/documentsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -442,13 +444,13 @@ def list_collections( search: nil, total: nil ) - api_path = '/documentsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -494,10 +496,7 @@ def create_collection( attributes: nil, indexes: nil ) - api_path = '/documentsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -509,6 +508,9 @@ def create_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { collectionId: collection_id, name: name, @@ -545,18 +547,18 @@ def get_collection( database_id:, collection_id: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { @@ -593,15 +595,11 @@ def update_collection( enabled: nil, purge: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -609,6 +607,10 @@ def update_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { name: name, permissions: permissions, @@ -643,23 +645,24 @@ def delete_collection( database_id:, collection_id: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -689,18 +692,18 @@ def list_documents( total: nil, ttl: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -743,15 +746,11 @@ def create_document( permissions: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -763,6 +762,10 @@ def create_document( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documentId: document_id, data: data, @@ -802,15 +805,11 @@ def create_documents( documents:, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -818,6 +817,10 @@ def create_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -856,15 +859,11 @@ def upsert_documents( documents:, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -872,6 +871,10 @@ def upsert_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -910,18 +913,18 @@ def update_documents( queries: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { data: data, queries: queries, @@ -958,18 +961,18 @@ def delete_documents( queries: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1007,23 +1010,23 @@ def get_document( queries: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1064,23 +1067,23 @@ def upsert_document( permissions: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1121,23 +1124,23 @@ def update_document( permissions: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1173,23 +1176,23 @@ def delete_document( document_id:, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { transactionId: transaction_id, } @@ -1197,6 +1200,7 @@ def delete_document( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1227,28 +1231,28 @@ def decrement_document_attribute( min: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, min: min, @@ -1290,28 +1294,28 @@ def increment_document_attribute( max: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, max: max, @@ -1347,18 +1351,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -1400,15 +1404,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1424,6 +1424,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "attributes"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, type: type, @@ -1459,23 +1463,23 @@ def get_index( collection_id:, key: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -1504,28 +1508,29 @@ def delete_index( collection_id:, key: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1554,13 +1559,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/documentsdb/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1597,13 +1602,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/documentsdb/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1633,13 +1638,13 @@ def list_operations( def get_replicas( database_id: ) - api_path = '/documentsdb/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1666,13 +1671,13 @@ def get_replicas( def get_status( database_id: ) - api_path = '/documentsdb/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/domains.rb b/lib/appwrite/services/domains.rb index 3493e9e4..42937c7d 100644 --- a/lib/appwrite/services/domains.rb +++ b/lib/appwrite/services/domains.rb @@ -174,7 +174,7 @@ def list_prices( def get( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -208,7 +208,7 @@ def get( def delete( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -243,7 +243,7 @@ def update_nameservers( domain_id:, nameservers: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -281,7 +281,7 @@ def update_nameservers( def verify_nameservers( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -313,7 +313,7 @@ def verify_nameservers( def get_preset_google_workspace( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -346,7 +346,7 @@ def get_preset_google_workspace( def create_preset_google_workspace( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -378,7 +378,7 @@ def create_preset_google_workspace( def get_preset_i_cloud( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -411,7 +411,7 @@ def get_preset_i_cloud( def create_preset_i_cloud( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -443,7 +443,7 @@ def create_preset_i_cloud( def get_preset_mailgun( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -476,7 +476,7 @@ def get_preset_mailgun( def create_preset_mailgun( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -508,7 +508,7 @@ def create_preset_mailgun( def get_preset_outlook( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -541,7 +541,7 @@ def get_preset_outlook( def create_preset_outlook( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -573,7 +573,7 @@ def create_preset_outlook( def get_preset_proton_mail( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -606,7 +606,7 @@ def get_preset_proton_mail( def create_preset_proton_mail( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -638,7 +638,7 @@ def create_preset_proton_mail( def get_preset_zoho( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -671,7 +671,7 @@ def get_preset_zoho( def create_preset_zoho( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -707,7 +707,7 @@ def list_records( domain_id:, queries: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -750,7 +750,7 @@ def create_record_a( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -813,11 +813,11 @@ def update_record_a( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -878,7 +878,7 @@ def create_record_aaaa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -941,11 +941,11 @@ def update_record_aaaa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1007,7 +1007,7 @@ def create_record_alias( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1073,11 +1073,11 @@ def update_record_alias( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1138,7 +1138,7 @@ def create_record_caa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1201,11 +1201,11 @@ def update_record_caa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1269,7 +1269,7 @@ def create_record_cname( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1328,11 +1328,11 @@ def update_record_cname( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1392,7 +1392,7 @@ def create_record_https( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1455,11 +1455,11 @@ def update_record_https( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1525,7 +1525,7 @@ def create_record_mx( priority:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1591,11 +1591,11 @@ def update_record_mx( priority:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1661,7 +1661,7 @@ def create_record_ns( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1726,11 +1726,11 @@ def update_record_ns( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1798,7 +1798,7 @@ def create_record_srv( port:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1891,11 +1891,11 @@ def update_record_srv( port:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1970,7 +1970,7 @@ def create_record_txt( value: nil, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2030,11 +2030,11 @@ def update_record_txt( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -2092,11 +2092,11 @@ def get_record( domain_id:, record_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -2132,11 +2132,11 @@ def delete_record( domain_id:, record_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -2176,7 +2176,7 @@ def update_team( domain_id:, team_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2215,7 +2215,7 @@ def update_team( def get_transfer_status( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2249,7 +2249,7 @@ def get_transfer_status( def get_zone( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2285,7 +2285,7 @@ def update_zone( domain_id:, content: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end diff --git a/lib/appwrite/services/embeddings.rb b/lib/appwrite/services/embeddings.rb index 3b7003db..e4fb2813 100644 --- a/lib/appwrite/services/embeddings.rb +++ b/lib/appwrite/services/embeddings.rb @@ -19,12 +19,12 @@ def create_text_embeddings( texts:, model: nil ) - api_path = '/embeddings/text' - if texts.nil? raise Appwrite::Exception.new('Missing required parameter: "texts"') end + api_path = '/embeddings/text' + api_params = { texts: texts, model: model, diff --git a/lib/appwrite/services/functions.rb b/lib/appwrite/services/functions.rb index dcf47e0c..2779fcd9 100644 --- a/lib/appwrite/services/functions.rb +++ b/lib/appwrite/services/functions.rb @@ -96,8 +96,6 @@ def create( deployment_retention: nil, interval: nil ) - api_path = '/functions' - if function_id.nil? raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -110,6 +108,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "runtime"') end + api_path = '/functions' + api_params = { functionId: function_id, name: name, @@ -218,13 +218,13 @@ def list_specifications( def get( function_id: ) - api_path = '/functions/{functionId}' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}' + .gsub('{functionId}', function_id) + api_params = {} api_headers = { @@ -266,6 +266,7 @@ def get( # @param [String] runtime_specification Runtime specification for the function executions. # @param [Integer] deployment_retention Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. # @param [Integer] interval Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. + # @param [] email_enabled Enable inbound email triggering for this function. When false or omitted on create, SMTP recipients are rejected. Opt-in; default is off. # # @return [Function] def update( @@ -291,12 +292,10 @@ def update( build_specification: nil, runtime_specification: nil, deployment_retention: nil, - interval: nil + interval: nil, + email_enabled: nil ) - api_path = '/functions/{functionId}' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -304,6 +303,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/functions/{functionId}' + .gsub('{functionId}', function_id) + api_params = { name: name, runtime: runtime, @@ -327,6 +329,7 @@ def update( runtimeSpecification: runtime_specification, deploymentRetention: deployment_retention, interval: interval, + emailEnabled: email_enabled, } api_headers = { @@ -352,18 +355,19 @@ def update( def delete( function_id: ) - api_path = '/functions/{functionId}' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}' + .gsub('{functionId}', function_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -385,10 +389,7 @@ def update_function_deployment( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployment' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -396,6 +397,9 @@ def update_function_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployment' + .gsub('{functionId}', function_id) + api_params = { deploymentId: deployment_id, } @@ -430,13 +434,13 @@ def list_deployments( search: nil, total: nil ) - api_path = '/functions/{functionId}/deployments' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/deployments' + .gsub('{functionId}', function_id) + api_params = { queries: queries, search: search, @@ -483,10 +487,7 @@ def create_deployment( commands: nil, on_progress: nil ) - api_path = '/functions/{functionId}/deployments' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -498,6 +499,9 @@ def create_deployment( raise Appwrite::Exception.new('Missing required parameter: "activate"') end + api_path = '/functions/{functionId}/deployments' + .gsub('{functionId}', function_id) + api_params = { entrypoint: entrypoint, commands: commands, @@ -521,6 +525,7 @@ def create_deployment( param_name: param_name, id_param_name: id_param_name, on_progress: on_progress, + method: 'POST', response_type: Models::Deployment ) end @@ -541,10 +546,7 @@ def create_duplicate_deployment( deployment_id:, build_id: nil ) - api_path = '/functions/{functionId}/deployments/duplicate' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -552,6 +554,9 @@ def create_duplicate_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/duplicate' + .gsub('{functionId}', function_id) + api_params = { deploymentId: deployment_id, buildId: build_id, @@ -596,10 +601,7 @@ def create_template_deployment( reference:, activate: nil ) - api_path = '/functions/{functionId}/deployments/template' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -623,6 +625,9 @@ def create_template_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/functions/{functionId}/deployments/template' + .gsub('{functionId}', function_id) + api_params = { repository: repository, owner: owner, @@ -663,10 +668,7 @@ def create_vcs_deployment( reference:, activate: nil ) - api_path = '/functions/{functionId}/deployments/vcs' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -678,6 +680,9 @@ def create_vcs_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/functions/{functionId}/deployments/vcs' + .gsub('{functionId}', function_id) + api_params = { type: type, reference: reference, @@ -709,18 +714,18 @@ def get_deployment( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployments/{deploymentId}' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -747,23 +752,24 @@ def delete_deployment( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployments/{deploymentId}' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -790,18 +796,18 @@ def get_deployment_download( type: nil, token: nil ) - api_path = '/functions/{functionId}/deployments/{deploymentId}/download' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}/download' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = { type: type, token: token, @@ -834,18 +840,18 @@ def update_deployment_status( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployments/{deploymentId}/status' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}/status' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -876,13 +882,13 @@ def list_executions( queries: nil, total: nil ) - api_path = '/functions/{functionId}/executions' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/executions' + .gsub('{functionId}', function_id) + api_params = { queries: queries, total: total, @@ -925,13 +931,13 @@ def create_execution( headers: nil, scheduled_at: nil ) - api_path = '/functions/{functionId}/executions' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/executions' + .gsub('{functionId}', function_id) + api_params = { body: body, async: async, @@ -966,18 +972,18 @@ def get_execution( function_id:, execution_id: ) - api_path = '/functions/{functionId}/executions/{executionId}' - .gsub('{functionId}', function_id) - .gsub('{executionId}', execution_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if execution_id.nil? + if execution_id.nil? || execution_id == '' raise Appwrite::Exception.new('Missing required parameter: "executionId"') end + api_path = '/functions/{functionId}/executions/{executionId}' + .gsub('{functionId}', function_id) + .gsub('{executionId}', execution_id) + api_params = {} api_headers = { @@ -1004,23 +1010,24 @@ def delete_execution( function_id:, execution_id: ) - api_path = '/functions/{functionId}/executions/{executionId}' - .gsub('{functionId}', function_id) - .gsub('{executionId}', execution_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if execution_id.nil? + if execution_id.nil? || execution_id == '' raise Appwrite::Exception.new('Missing required parameter: "executionId"') end + api_path = '/functions/{functionId}/executions/{executionId}' + .gsub('{functionId}', function_id) + .gsub('{executionId}', execution_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1043,13 +1050,13 @@ def list_variables( queries: nil, total: nil ) - api_path = '/functions/{functionId}/variables' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/variables' + .gsub('{functionId}', function_id) + api_params = { queries: queries, total: total, @@ -1086,10 +1093,7 @@ def create_variable( value:, secret: nil ) - api_path = '/functions/{functionId}/variables' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -1105,6 +1109,9 @@ def create_variable( raise Appwrite::Exception.new('Missing required parameter: "value"') end + api_path = '/functions/{functionId}/variables' + .gsub('{functionId}', function_id) + api_params = { variableId: variable_id, key: key, @@ -1137,18 +1144,18 @@ def get_variable( function_id:, variable_id: ) - api_path = '/functions/{functionId}/variables/{variableId}' - .gsub('{functionId}', function_id) - .gsub('{variableId}', variable_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/functions/{functionId}/variables/{variableId}' + .gsub('{functionId}', function_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { @@ -1181,18 +1188,18 @@ def update_variable( value: nil, secret: nil ) - api_path = '/functions/{functionId}/variables/{variableId}' - .gsub('{functionId}', function_id) - .gsub('{variableId}', variable_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/functions/{functionId}/variables/{variableId}' + .gsub('{functionId}', function_id) + .gsub('{variableId}', variable_id) + api_params = { key: key, value: value, @@ -1224,23 +1231,24 @@ def delete_variable( function_id:, variable_id: ) - api_path = '/functions/{functionId}/variables/{variableId}' - .gsub('{functionId}', function_id) - .gsub('{variableId}', variable_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/functions/{functionId}/variables/{variableId}' + .gsub('{functionId}', function_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/graphql.rb b/lib/appwrite/services/graphql.rb index 210f528a..7a13b000 100644 --- a/lib/appwrite/services/graphql.rb +++ b/lib/appwrite/services/graphql.rb @@ -14,12 +14,12 @@ def initialize(client) def query( query: ) - api_path = '/graphql' - if query.nil? raise Appwrite::Exception.new('Missing required parameter: "query"') end + api_path = '/graphql' + api_params = { query: query, } @@ -47,12 +47,12 @@ def query( def mutation( query: ) - api_path = '/graphql/mutation' - if query.nil? raise Appwrite::Exception.new('Missing required parameter: "query"') end + api_path = '/graphql/mutation' + api_params = { query: query, } diff --git a/lib/appwrite/services/messaging.rb b/lib/appwrite/services/messaging.rb index ab97d81c..e37e067d 100644 --- a/lib/appwrite/services/messaging.rb +++ b/lib/appwrite/services/messaging.rb @@ -8,7 +8,7 @@ def initialize(client) # Get a list of all messages from the current Appwrite project. # - # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType + # @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: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType, users, targets # @param [String] search Search term to filter your list results. Max length: 256 chars. # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # @@ -74,8 +74,6 @@ def create_email( reply_to_email: nil, reply_to_name: nil ) - api_path = '/messaging/messages/email' - if message_id.nil? raise Appwrite::Exception.new('Missing required parameter: "messageId"') end @@ -88,6 +86,8 @@ def create_email( raise Appwrite::Exception.new('Missing required parameter: "content"') end + api_path = '/messaging/messages/email' + api_params = { messageId: message_id, subject: subject, @@ -157,13 +157,13 @@ def update_email( reply_to_email: nil, reply_to_name: nil ) - api_path = '/messaging/messages/email/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/email/{messageId}' + .gsub('{messageId}', message_id) + api_params = { topics: topics, users: users, @@ -241,12 +241,12 @@ def create_push( priority: nil, channel_id: nil ) - api_path = '/messaging/messages/push' - if message_id.nil? raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/push' + api_params = { messageId: message_id, title: title, @@ -334,13 +334,13 @@ def update_push( priority: nil, channel_id: nil ) - api_path = '/messaging/messages/push/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/push/{messageId}' + .gsub('{messageId}', message_id) + api_params = { topics: topics, users: users, @@ -398,8 +398,6 @@ def create_sms( draft: nil, scheduled_at: nil ) - api_path = '/messaging/messages/sms' - if message_id.nil? raise Appwrite::Exception.new('Missing required parameter: "messageId"') end @@ -408,6 +406,8 @@ def create_sms( raise Appwrite::Exception.new('Missing required parameter: "content"') end + api_path = '/messaging/messages/sms' + api_params = { messageId: message_id, content: content, @@ -456,13 +456,13 @@ def update_sms( draft: nil, scheduled_at: nil ) - api_path = '/messaging/messages/sms/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/sms/{messageId}' + .gsub('{messageId}', message_id) + api_params = { topics: topics, users: users, @@ -496,13 +496,13 @@ def update_sms( def get_message( message_id: ) - api_path = '/messaging/messages/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/{messageId}' + .gsub('{messageId}', message_id) + api_params = {} api_headers = { @@ -528,18 +528,19 @@ def get_message( def delete( message_id: ) - api_path = '/messaging/messages/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/{messageId}' + .gsub('{messageId}', message_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -562,13 +563,13 @@ def list_targets( queries: nil, total: nil ) - api_path = '/messaging/messages/{messageId}/targets' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/{messageId}/targets' + .gsub('{messageId}', message_id) + api_params = { queries: queries, total: total, @@ -644,8 +645,6 @@ def create_apns_provider( sandbox: nil, enabled: nil ) - api_path = '/messaging/providers/apns' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -654,6 +653,8 @@ def create_apns_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/apns' + api_params = { providerId: provider_id, name: name, @@ -702,13 +703,13 @@ def update_apns_provider( bundle_id: nil, sandbox: nil ) - api_path = '/messaging/providers/apns/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/apns/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -740,7 +741,7 @@ def update_apns_provider( # @param [String] name Provider name. # @param [] enabled Set as enabled. # @param [Integer] qos Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. # # @return [Provider] def create_appwrite_provider( @@ -789,7 +790,7 @@ def create_appwrite_provider( # @param [String] name Provider name. # @param [] enabled Set as enabled. # @param [Integer] qos Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. # # @return [Provider] def update_appwrite_provider( @@ -799,7 +800,7 @@ def update_appwrite_provider( qos: nil, expiry: nil ) - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -842,8 +843,6 @@ def create_fcm_provider( service_account_json: nil, enabled: nil ) - api_path = '/messaging/providers/fcm' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -852,6 +851,8 @@ def create_fcm_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/fcm' + api_params = { providerId: provider_id, name: name, @@ -888,13 +889,13 @@ def update_fcm_provider( enabled: nil, service_account_json: nil ) - api_path = '/messaging/providers/fcm/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/fcm/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -942,8 +943,6 @@ def create_mailgun_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/mailgun' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -952,6 +951,8 @@ def create_mailgun_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/mailgun' + api_params = { providerId: provider_id, name: name, @@ -1006,13 +1007,13 @@ def update_mailgun_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/mailgun/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/mailgun/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, apiKey: api_key, @@ -1058,8 +1059,6 @@ def create_msg91_provider( auth_key: nil, enabled: nil ) - api_path = '/messaging/providers/msg91' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1068,6 +1067,8 @@ def create_msg91_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/msg91' + api_params = { providerId: provider_id, name: name, @@ -1110,13 +1111,13 @@ def update_msg91_provider( sender_id: nil, auth_key: nil ) - api_path = '/messaging/providers/msg91/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/msg91/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1162,8 +1163,6 @@ def create_resend_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/resend' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1172,6 +1171,8 @@ def create_resend_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/resend' + api_params = { providerId: provider_id, name: name, @@ -1220,13 +1221,13 @@ def update_resend_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/resend/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/resend/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1274,8 +1275,6 @@ def create_sendgrid_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/sendgrid' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1284,6 +1283,8 @@ def create_sendgrid_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/sendgrid' + api_params = { providerId: provider_id, name: name, @@ -1332,13 +1333,13 @@ def update_sendgrid_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/sendgrid/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/sendgrid/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1390,8 +1391,6 @@ def create_ses_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/ses' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1400,6 +1399,8 @@ def create_ses_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/ses' + api_params = { providerId: provider_id, name: name, @@ -1454,13 +1455,13 @@ def update_ses_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/ses/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/ses/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1522,8 +1523,6 @@ def create_smtp_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/smtp' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1536,6 +1535,8 @@ def create_smtp_provider( raise Appwrite::Exception.new('Missing required parameter: "host"') end + api_path = '/messaging/providers/smtp' + api_params = { providerId: provider_id, name: name, @@ -1602,13 +1603,13 @@ def update_smtp_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/smtp/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/smtp/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, host: host, @@ -1658,8 +1659,6 @@ def create_telesign_provider( api_key: nil, enabled: nil ) - api_path = '/messaging/providers/telesign' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1668,6 +1667,8 @@ def create_telesign_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/telesign' + api_params = { providerId: provider_id, name: name, @@ -1710,13 +1711,13 @@ def update_telesign_provider( api_key: nil, from: nil ) - api_path = '/messaging/providers/telesign/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/telesign/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1758,8 +1759,6 @@ def create_textmagic_provider( api_key: nil, enabled: nil ) - api_path = '/messaging/providers/textmagic' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1768,6 +1767,8 @@ def create_textmagic_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/textmagic' + api_params = { providerId: provider_id, name: name, @@ -1810,13 +1811,13 @@ def update_textmagic_provider( api_key: nil, from: nil ) - api_path = '/messaging/providers/textmagic/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/textmagic/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1844,7 +1845,7 @@ def update_textmagic_provider( # # @param [String] provider_id Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. # @param [String] name Provider name. - # @param [String] from Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + # @param [String] from Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. # @param [String] account_sid Twilio account secret ID. # @param [String] auth_token Twilio authentication token. # @param [] enabled Set as enabled. @@ -1858,8 +1859,6 @@ def create_twilio_provider( auth_token: nil, enabled: nil ) - api_path = '/messaging/providers/twilio' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1868,6 +1867,8 @@ def create_twilio_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/twilio' + api_params = { providerId: provider_id, name: name, @@ -1899,7 +1900,7 @@ def create_twilio_provider( # @param [] enabled Set as enabled. # @param [String] account_sid Twilio account secret ID. # @param [String] auth_token Twilio authentication token. - # @param [String] from Sender number. + # @param [String] from Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. # # @return [Provider] def update_twilio_provider( @@ -1910,13 +1911,13 @@ def update_twilio_provider( auth_token: nil, from: nil ) - api_path = '/messaging/providers/twilio/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/twilio/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1958,8 +1959,6 @@ def create_vonage_provider( api_secret: nil, enabled: nil ) - api_path = '/messaging/providers/vonage' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1968,6 +1967,8 @@ def create_vonage_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/vonage' + api_params = { providerId: provider_id, name: name, @@ -2010,13 +2011,13 @@ def update_vonage_provider( api_secret: nil, from: nil ) - api_path = '/messaging/providers/vonage/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/vonage/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -2049,13 +2050,13 @@ def update_vonage_provider( def get_provider( provider_id: ) - api_path = '/messaging/providers/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/{providerId}' + .gsub('{providerId}', provider_id) + api_params = {} api_headers = { @@ -2080,18 +2081,19 @@ def get_provider( def delete_provider( provider_id: ) - api_path = '/messaging/providers/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/{providerId}' + .gsub('{providerId}', provider_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -2142,7 +2144,7 @@ def list_topics( # @param [String] name Topic Name. # @param [Array] subscribe An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. # @param [Integer] qos MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. # # @return [Topic] def create_topic( @@ -2152,8 +2154,6 @@ def create_topic( qos: nil, expiry: nil ) - api_path = '/messaging/topics' - if topic_id.nil? raise Appwrite::Exception.new('Missing required parameter: "topicId"') end @@ -2162,6 +2162,8 @@ def create_topic( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/topics' + api_params = { topicId: topic_id, name: name, @@ -2194,13 +2196,13 @@ def create_topic( def get_topic( topic_id: ) - api_path = '/messaging/topics/{topicId}' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}' + .gsub('{topicId}', topic_id) + api_params = {} api_headers = { @@ -2224,7 +2226,7 @@ def get_topic( # @param [String] name Topic Name. # @param [Array] subscribe An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. # @param [Integer] qos MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. # # @return [Topic] def update_topic( @@ -2234,13 +2236,13 @@ def update_topic( qos: nil, expiry: nil ) - api_path = '/messaging/topics/{topicId}' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}' + .gsub('{topicId}', topic_id) + api_params = { name: name, subscribe: subscribe, @@ -2271,18 +2273,19 @@ def update_topic( def delete_topic( topic_id: ) - api_path = '/messaging/topics/{topicId}' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}' + .gsub('{topicId}', topic_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -2307,13 +2310,13 @@ def list_subscribers( search: nil, total: nil ) - api_path = '/messaging/topics/{topicId}/subscribers' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}/subscribers' + .gsub('{topicId}', topic_id) + api_params = { queries: queries, search: search, @@ -2346,10 +2349,7 @@ def create_subscriber( subscriber_id:, target_id: ) - api_path = '/messaging/topics/{topicId}/subscribers' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end @@ -2361,6 +2361,9 @@ def create_subscriber( raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/messaging/topics/{topicId}/subscribers' + .gsub('{topicId}', topic_id) + api_params = { subscriberId: subscriber_id, targetId: target_id, @@ -2392,18 +2395,18 @@ def get_subscriber( topic_id:, subscriber_id: ) - api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' - .gsub('{topicId}', topic_id) - .gsub('{subscriberId}', subscriber_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end - if subscriber_id.nil? + if subscriber_id.nil? || subscriber_id == '' raise Appwrite::Exception.new('Missing required parameter: "subscriberId"') end + api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .gsub('{topicId}', topic_id) + .gsub('{subscriberId}', subscriber_id) + api_params = {} api_headers = { @@ -2430,23 +2433,24 @@ def delete_subscriber( topic_id:, subscriber_id: ) - api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' - .gsub('{topicId}', topic_id) - .gsub('{subscriberId}', subscriber_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end - if subscriber_id.nil? + if subscriber_id.nil? || subscriber_id == '' raise Appwrite::Exception.new('Missing required parameter: "subscriberId"') end + api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .gsub('{topicId}', topic_id) + .gsub('{subscriberId}', subscriber_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/mongo.rb b/lib/appwrite/services/mongo.rb index 0c95972a..7c968604 100644 --- a/lib/appwrite/services/mongo.rb +++ b/lib/appwrite/services/mongo.rb @@ -50,7 +50,7 @@ def list( # @param [Integer] pitr_retention_days Number of days to retain PITR data. # @param [] storage_autoscaling Enable automatic storage expansion when usage exceeds threshold. # @param [Integer] storage_autoscaling_threshold_percent Storage usage percentage (50-95) that triggers automatic expansion. - # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. 0 means no limit. + # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. # # @return [DedicatedDatabase] def create( @@ -69,8 +69,6 @@ def create( storage_autoscaling_threshold_percent: nil, storage_autoscaling_max_gb: nil ) - api_path = '/mongo' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -79,6 +77,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/mongo' + api_params = { databaseId: database_id, name: name, @@ -112,8 +112,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -145,13 +145,13 @@ def list_specifications() def get( database_id: ) - api_path = '/mongo/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update( sql_api_max_bytes: nil, sql_api_timeout_seconds: nil ) - api_path = '/mongo/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, status: status, @@ -275,13 +275,13 @@ def update( def delete( database_id: ) - api_path = '/mongo/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -309,13 +309,13 @@ def list_backups( database_id:, queries: nil ) - api_path = '/mongo/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -345,13 +345,13 @@ def create_backup( database_id:, type: nil ) - api_path = '/mongo/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { type: type, } @@ -381,13 +381,13 @@ def list_backup_policies( database_id:, queries: nil ) - api_path = '/mongo/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -426,10 +426,7 @@ def create_backup_policy( type: nil, enabled: nil ) - api_path = '/mongo/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -449,6 +446,9 @@ def create_backup_policy( raise Appwrite::Exception.new('Missing required parameter: "retention"') end + api_path = '/mongo/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { policyId: policy_id, name: name, @@ -483,18 +483,18 @@ def get_backup_policy( database_id:, policy_id: ) - api_path = '/mongo/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mongo/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -529,18 +529,18 @@ def update_backup_policy( retention: nil, enabled: nil ) - api_path = '/mongo/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mongo/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = { name: name, schedule: schedule, @@ -574,18 +574,18 @@ def delete_backup_policy( database_id:, policy_id: ) - api_path = '/mongo/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mongo/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -626,10 +626,7 @@ def update_backup_storage( prefix: nil, endpoint: nil ) - api_path = '/mongo/{databaseId}/backups/storage' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -649,6 +646,9 @@ def update_backup_storage( raise Appwrite::Exception.new('Missing required parameter: "secretKey"') end + api_path = '/mongo/{databaseId}/backups/storage' + .gsub('{databaseId}', database_id) + api_params = { provider: provider, bucket: bucket, @@ -685,18 +685,18 @@ def get_backup( database_id:, backup_id: ) - api_path = '/mongo/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mongo/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -724,18 +724,18 @@ def delete_backup( database_id:, backup_id: ) - api_path = '/mongo/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mongo/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -761,13 +761,13 @@ def delete_backup( def list_branches( database_id: ) - api_path = '/mongo/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -800,13 +800,13 @@ def create_branch( branch_id: nil, ttl: nil ) - api_path = '/mongo/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = { branchId: branch_id, ttl: ttl, @@ -839,18 +839,18 @@ def delete_branch( database_id:, branch_id: ) - api_path = '/mongo/{databaseId}/branches/{branchId}' - .gsub('{databaseId}', database_id) - .gsub('{branchId}', branch_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if branch_id.nil? + if branch_id.nil? || branch_id == '' raise Appwrite::Exception.new('Missing required parameter: "branchId"') end + api_path = '/mongo/{databaseId}/branches/{branchId}' + .gsub('{databaseId}', database_id) + .gsub('{branchId}', branch_id) + api_params = {} api_headers = { @@ -879,13 +879,13 @@ def delete_branch( def update_credentials( database_id: ) - api_path = '/mongo/{databaseId}/credentials' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/credentials' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -921,13 +921,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/mongo/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -961,10 +961,7 @@ def update_maintenance( day:, hour_utc: ) - api_path = '/mongo/{databaseId}/maintenance' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -976,6 +973,9 @@ def update_maintenance( raise Appwrite::Exception.new('Missing required parameter: "hourUtc"') end + api_path = '/mongo/{databaseId}/maintenance' + .gsub('{databaseId}', database_id) + api_params = { day: day, hourUtc: hour_utc, @@ -1011,10 +1011,7 @@ def create_migration( target_type:, specification: nil ) - api_path = '/mongo/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1022,6 +1019,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "targetType"') end + api_path = '/mongo/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { targetType: target_type, specification: specification, @@ -1059,13 +1059,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/mongo/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1095,13 +1095,13 @@ def list_operations( def get_pitr( database_id: ) - api_path = '/mongo/{databaseId}/pitr' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/pitr' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1127,13 +1127,13 @@ def get_pitr( def get_replicas( database_id: ) - api_path = '/mongo/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1167,13 +1167,13 @@ def list_restorations( limit: nil, offset: nil ) - api_path = '/mongo/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { status: status, type: type, @@ -1200,11 +1200,25 @@ def list_restorations( # an ISO 8601 datetime. PITR requires the database to have PITR enabled and # is only available for enterprise databases. # + # By default the backup is replayed over the database it was taken from. Pass + # `restoreMode` as `clone` to recover it onto a second workload beside this + # database instead: this database keeps serving its own data while the clone + # is filled, and the switch happens as soon as the clone is ready, on the + # endpoint and credentials it already had. Pass `autoPromote` as false to + # hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + # to recover onto a separate database with its own endpoint, either one you + # name with `targetDatabaseId` or one provisioned as a copy of this + # database's engine, version, specification and replicas. Neither mode is + # available for a point-in-time recovery or an incremental backup. + # # @param [String] database_id Database ID. # @param [String] type Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. # @param [String] backup_id Backup ID to restore from (required for backup type). - # @param [String] target_database_id Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + # @param [String] target_database_id Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. # @param [String] target_time Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. + # @param [String] restore_mode Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + # @param [String] target_name Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + # @param [] auto_promote Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. # # @return [DedicatedDatabaseRestoration] def create_restoration( @@ -1212,20 +1226,26 @@ def create_restoration( type: nil, backup_id: nil, target_database_id: nil, - target_time: nil + target_time: nil, + restore_mode: nil, + target_name: nil, + auto_promote: nil ) - api_path = '/mongo/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { type: type, backupId: backup_id, targetDatabaseId: target_database_id, targetTime: target_time, + restoreMode: restore_mode, + targetName: target_name, + autoPromote: auto_promote, } api_headers = { @@ -1254,27 +1274,71 @@ def get_restoration( database_id:, restoration_id: ) + if database_id.nil? || database_id == '' + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if restoration_id.nil? || restoration_id == '' + raise Appwrite::Exception.new('Missing required parameter: "restorationId"') + end + api_path = '/mongo/{databaseId}/restorations/{restorationId}' .gsub('{databaseId}', database_id) .gsub('{restorationId}', restoration_id) - if database_id.nil? + 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::DedicatedDatabaseRestoration + ) + end + + # Switch the database over to the clone a restoration recovered. The database + # keeps + # its endpoint and credentials; clients reconnect once. Writes made after the + # recovery point are discarded, and the side being replaced is retained + # briefly so + # the switch can be reversed. + # + # @param [String] database_id Database ID. + # @param [String] restoration_id Restoration ID. + # + # @return [DedicatedDatabaseRestoration] + def promote_restoration( + database_id:, + restoration_id: + ) + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/mongo/{databaseId}/restorations/{restorationId}/promotions' + .gsub('{databaseId}', database_id) + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', "accept": 'application/json', } @client.call( - method: 'GET', + method: 'POST', path: api_path, headers: api_headers, params: api_params, @@ -1292,13 +1356,13 @@ def get_restoration( def get_status( database_id: ) - api_path = '/mongo/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1326,10 +1390,7 @@ def create_upgrade( database_id:, target_version: ) - api_path = '/mongo/{databaseId}/upgrades' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1337,6 +1398,9 @@ def create_upgrade( raise Appwrite::Exception.new('Missing required parameter: "targetVersion"') end + api_path = '/mongo/{databaseId}/upgrades' + .gsub('{databaseId}', database_id) + api_params = { targetVersion: target_version, } diff --git a/lib/appwrite/services/mysql.rb b/lib/appwrite/services/mysql.rb index 2e21c83c..d7bdca2b 100644 --- a/lib/appwrite/services/mysql.rb +++ b/lib/appwrite/services/mysql.rb @@ -50,7 +50,7 @@ def list( # @param [Integer] pitr_retention_days Number of days to retain PITR data. # @param [] storage_autoscaling Enable automatic storage expansion when usage exceeds threshold. # @param [Integer] storage_autoscaling_threshold_percent Storage usage percentage (50-95) that triggers automatic expansion. - # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. 0 means no limit. + # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. # # @return [DedicatedDatabase] def create( @@ -69,8 +69,6 @@ def create( storage_autoscaling_threshold_percent: nil, storage_autoscaling_max_gb: nil ) - api_path = '/mysql' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -79,6 +77,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/mysql' + api_params = { databaseId: database_id, name: name, @@ -112,8 +112,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -145,13 +145,13 @@ def list_specifications() def get( database_id: ) - api_path = '/mysql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update( sql_api_max_bytes: nil, sql_api_timeout_seconds: nil ) - api_path = '/mysql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, status: status, @@ -275,13 +275,13 @@ def update( def delete( database_id: ) - api_path = '/mysql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -309,13 +309,13 @@ def list_backups( database_id:, queries: nil ) - api_path = '/mysql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -345,13 +345,13 @@ def create_backup( database_id:, type: nil ) - api_path = '/mysql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { type: type, } @@ -381,13 +381,13 @@ def list_backup_policies( database_id:, queries: nil ) - api_path = '/mysql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -426,10 +426,7 @@ def create_backup_policy( type: nil, enabled: nil ) - api_path = '/mysql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -449,6 +446,9 @@ def create_backup_policy( raise Appwrite::Exception.new('Missing required parameter: "retention"') end + api_path = '/mysql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { policyId: policy_id, name: name, @@ -483,18 +483,18 @@ def get_backup_policy( database_id:, policy_id: ) - api_path = '/mysql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mysql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -529,18 +529,18 @@ def update_backup_policy( retention: nil, enabled: nil ) - api_path = '/mysql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mysql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = { name: name, schedule: schedule, @@ -574,18 +574,18 @@ def delete_backup_policy( database_id:, policy_id: ) - api_path = '/mysql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mysql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -626,10 +626,7 @@ def update_backup_storage( prefix: nil, endpoint: nil ) - api_path = '/mysql/{databaseId}/backups/storage' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -649,6 +646,9 @@ def update_backup_storage( raise Appwrite::Exception.new('Missing required parameter: "secretKey"') end + api_path = '/mysql/{databaseId}/backups/storage' + .gsub('{databaseId}', database_id) + api_params = { provider: provider, bucket: bucket, @@ -685,18 +685,18 @@ def get_backup( database_id:, backup_id: ) - api_path = '/mysql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mysql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -724,18 +724,18 @@ def delete_backup( database_id:, backup_id: ) - api_path = '/mysql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mysql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -761,13 +761,13 @@ def delete_backup( def list_branches( database_id: ) - api_path = '/mysql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -800,13 +800,13 @@ def create_branch( branch_id: nil, ttl: nil ) - api_path = '/mysql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = { branchId: branch_id, ttl: ttl, @@ -839,18 +839,18 @@ def delete_branch( database_id:, branch_id: ) - api_path = '/mysql/{databaseId}/branches/{branchId}' - .gsub('{databaseId}', database_id) - .gsub('{branchId}', branch_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if branch_id.nil? + if branch_id.nil? || branch_id == '' raise Appwrite::Exception.new('Missing required parameter: "branchId"') end + api_path = '/mysql/{databaseId}/branches/{branchId}' + .gsub('{databaseId}', database_id) + .gsub('{branchId}', branch_id) + api_params = {} api_headers = { @@ -879,13 +879,13 @@ def delete_branch( def update_credentials( database_id: ) - api_path = '/mysql/{databaseId}/credentials' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/credentials' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -912,11 +912,15 @@ def update_credentials( # without a per-query cloud round-trip. The statement type must be on the # database's configured allow-list. Use bound parameters for any # user-supplied values — the API does not interpolate raw strings. + # Long-running statements (for example CREATE INDEX) can outlive the HTTP + # request: if the request ends before a result is returned, check the + # database before retrying, and prefer a direct connection for work that may + # take minutes. # # @param [String] database_id Database ID. # @param [String] sql SQL statement to execute. Exactly one statement per request. # @param [Hash] bindings Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. - # @param [Integer] timeout_seconds Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. + # @param [Integer] timeout_seconds Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. # # @return [DedicatedDatabaseExecution] def create_execution( @@ -925,10 +929,7 @@ def create_execution( bindings: nil, timeout_seconds: nil ) - api_path = '/mysql/{databaseId}/executions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -936,6 +937,9 @@ def create_execution( raise Appwrite::Exception.new('Missing required parameter: "sql"') end + api_path = '/mysql/{databaseId}/executions' + .gsub('{databaseId}', database_id) + api_params = { sql: sql, bindings: bindings, @@ -975,13 +979,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/mysql/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1015,10 +1019,7 @@ def update_maintenance( day:, hour_utc: ) - api_path = '/mysql/{databaseId}/maintenance' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1030,6 +1031,9 @@ def update_maintenance( raise Appwrite::Exception.new('Missing required parameter: "hourUtc"') end + api_path = '/mysql/{databaseId}/maintenance' + .gsub('{databaseId}', database_id) + api_params = { day: day, hourUtc: hour_utc, @@ -1065,10 +1069,7 @@ def create_migration( target_type:, specification: nil ) - api_path = '/mysql/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1076,6 +1077,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "targetType"') end + api_path = '/mysql/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { targetType: target_type, specification: specification, @@ -1113,13 +1117,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/mysql/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1149,13 +1153,13 @@ def list_operations( def get_pitr( database_id: ) - api_path = '/mysql/{databaseId}/pitr' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/pitr' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1181,13 +1185,13 @@ def get_pitr( def get_pooler( database_id: ) - api_path = '/mysql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1211,7 +1215,7 @@ def get_pooler( # @param [String] mode Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. # @param [Integer] max_connections Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. # @param [Integer] default_pool_size Default pool size per user. - # @param [] read_write_splitting Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + # @param [] read_write_splitting Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. # @param [String] pooler_cpu_request Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). # @param [String] pooler_cpu_limit Pooler sidecar CPU limit override (Kubernetes quantity, e.g. "500m" or "1"). Leave null for the proportional default (10% of DB CPU, floor 200m). Changing this field rolls the database pod. # @param [String] pooler_memory_request Pooler sidecar memory request override (Kubernetes quantity, e.g. "128Mi" or "1Gi"). Leave null for the proportional default (7.5% of DB memory, floor 64Mi). @@ -1229,13 +1233,13 @@ def update_pooler( pooler_memory_request: nil, pooler_memory_limit: nil ) - api_path = '/mysql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = { mode: mode, maxConnections: max_connections, @@ -1271,13 +1275,13 @@ def update_pooler( def get_replicas( database_id: ) - api_path = '/mysql/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1311,13 +1315,13 @@ def list_restorations( limit: nil, offset: nil ) - api_path = '/mysql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { status: status, type: type, @@ -1344,11 +1348,25 @@ def list_restorations( # an ISO 8601 datetime. PITR requires the database to have PITR enabled and # is only available for enterprise databases. # + # By default the backup is replayed over the database it was taken from. Pass + # `restoreMode` as `clone` to recover it onto a second workload beside this + # database instead: this database keeps serving its own data while the clone + # is filled, and the switch happens as soon as the clone is ready, on the + # endpoint and credentials it already had. Pass `autoPromote` as false to + # hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + # to recover onto a separate database with its own endpoint, either one you + # name with `targetDatabaseId` or one provisioned as a copy of this + # database's engine, version, specification and replicas. Neither mode is + # available for a point-in-time recovery or an incremental backup. + # # @param [String] database_id Database ID. # @param [String] type Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. # @param [String] backup_id Backup ID to restore from (required for backup type). - # @param [String] target_database_id Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + # @param [String] target_database_id Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. # @param [String] target_time Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. + # @param [String] restore_mode Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + # @param [String] target_name Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + # @param [] auto_promote Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. # # @return [DedicatedDatabaseRestoration] def create_restoration( @@ -1356,20 +1374,26 @@ def create_restoration( type: nil, backup_id: nil, target_database_id: nil, - target_time: nil + target_time: nil, + restore_mode: nil, + target_name: nil, + auto_promote: nil ) - api_path = '/mysql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { type: type, backupId: backup_id, targetDatabaseId: target_database_id, targetTime: target_time, + restoreMode: restore_mode, + targetName: target_name, + autoPromote: auto_promote, } api_headers = { @@ -1398,27 +1422,71 @@ def get_restoration( database_id:, restoration_id: ) + if database_id.nil? || database_id == '' + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if restoration_id.nil? || restoration_id == '' + raise Appwrite::Exception.new('Missing required parameter: "restorationId"') + end + api_path = '/mysql/{databaseId}/restorations/{restorationId}' .gsub('{databaseId}', database_id) .gsub('{restorationId}', restoration_id) - if database_id.nil? + 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::DedicatedDatabaseRestoration + ) + end + + # Switch the database over to the clone a restoration recovered. The database + # keeps + # its endpoint and credentials; clients reconnect once. Writes made after the + # recovery point are discarded, and the side being replaced is retained + # briefly so + # the switch can be reversed. + # + # @param [String] database_id Database ID. + # @param [String] restoration_id Restoration ID. + # + # @return [DedicatedDatabaseRestoration] + def promote_restoration( + database_id:, + restoration_id: + ) + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/mysql/{databaseId}/restorations/{restorationId}/promotions' + .gsub('{databaseId}', database_id) + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', "accept": 'application/json', } @client.call( - method: 'GET', + method: 'POST', path: api_path, headers: api_headers, params: api_params, @@ -1436,13 +1504,13 @@ def get_restoration( def get_status( database_id: ) - api_path = '/mysql/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1470,10 +1538,7 @@ def create_upgrade( database_id:, target_version: ) - api_path = '/mysql/{databaseId}/upgrades' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1481,6 +1546,9 @@ def create_upgrade( raise Appwrite::Exception.new('Missing required parameter: "targetVersion"') end + api_path = '/mysql/{databaseId}/upgrades' + .gsub('{databaseId}', database_id) + api_params = { targetVersion: target_version, } diff --git a/lib/appwrite/services/oauth2.rb b/lib/appwrite/services/oauth2.rb index 33402a28..0571d694 100644 --- a/lib/appwrite/services/oauth2.rb +++ b/lib/appwrite/services/oauth2.rb @@ -22,13 +22,13 @@ def approve( 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_path = '/oauth2/{project_id}/approve' + .gsub('{project_id}', @client.get_config('project')) + api_params = { grant_id: grant_id, authorization_details: authorization_details, @@ -66,7 +66,7 @@ def approve( # @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 [Array] 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. # @@ -137,7 +137,7 @@ def authorize( # @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 [Array] 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. # @@ -198,7 +198,7 @@ def authorize_post( # @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 [Array] 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] @@ -245,13 +245,13 @@ def create_device_authorization( 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_path = '/oauth2/{project_id}/grants' + .gsub('{project_id}', @client.get_config('project')) + api_params = { user_code: user_code, } @@ -280,14 +280,14 @@ def create_grant( def get_grant( grant_id: ) + if grant_id.nil? || grant_id == '' + raise Appwrite::Exception.new('Missing required parameter: "grantId"') + end + 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 = { @@ -398,7 +398,7 @@ def list_organizations( # @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 [Array] 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] @@ -417,9 +417,6 @@ def create_par( 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 @@ -432,6 +429,9 @@ def create_par( raise Appwrite::Exception.new('Missing required parameter: "responseType"') end + api_path = '/oauth2/{project_id}/par' + .gsub('{project_id}', @client.get_config('project')) + api_params = { client_id: client_id, redirect_uri: redirect_uri, @@ -509,13 +509,13 @@ def list_projects( 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_path = '/oauth2/{project_id}/reject' + .gsub('{project_id}', @client.get_config('project')) + api_params = { grant_id: grant_id, } @@ -548,13 +548,13 @@ def revoke( 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_path = '/oauth2/{project_id}/revoke' + .gsub('{project_id}', @client.get_config('project')) + api_params = { token: token, token_type_hint: token_type_hint, @@ -586,7 +586,7 @@ def revoke( # @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 [Array] 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] @@ -602,13 +602,13 @@ def create_token( 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_path = '/oauth2/{project_id}/token' + .gsub('{project_id}', @client.get_config('project')) + api_params = { grant_type: grant_type, code: code, diff --git a/lib/appwrite/services/organization.rb b/lib/appwrite/services/organization.rb index b43b8f29..e086c703 100644 --- a/lib/appwrite/services/organization.rb +++ b/lib/appwrite/services/organization.rb @@ -37,12 +37,12 @@ def get() def update( name: ) - api_path = '/organization' - if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/organization' + api_params = { name: name, } @@ -75,6 +75,7 @@ def delete() api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -129,12 +130,12 @@ 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_path = '/organization/installations' + api_params = { appId: app_id, authorizationDetails: authorization_details, @@ -164,13 +165,13 @@ def create_installation( def get_installation( installation_id: ) - api_path = '/organization/installations/{installationId}' - .gsub('{installationId}', installation_id) - - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -200,13 +201,13 @@ def update_installation( installation_id:, authorization_details: nil ) - api_path = '/organization/installations/{installationId}' - .gsub('{installationId}', installation_id) - - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) + api_params = { authorizationDetails: authorization_details, } @@ -236,216 +237,21 @@ def update_installation( def delete_installation( installation_id: ) - api_path = '/organization/installations/{installationId}' - .gsub('{installationId}', installation_id) - - if installation_id.nil? + if installation_id.nil? || installation_id == '' 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 - # @param [] total When set to false, the total count returned will be 0 and will not be calculated. - # - # @return [KeyList] - def list_keys( - queries: nil, - total: nil - ) - api_path = '/organization/keys' - - api_params = { - queries: queries, - total: total, - } - - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), - "accept": 'application/json', - } - - @client.call( - method: 'GET', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::KeyList - ) - end - - # Create a new organization API key. - # - # @param [String] key_id Key ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - # @param [String] name Key name. Max length: 128 chars. - # @param [Array] scopes Key scopes list. Maximum of 200 scopes are allowed. - # @param [String] expire Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - # - # @return [Key] - def create_key( - key_id:, - name:, - scopes:, - expire: nil - ) - api_path = '/organization/keys' - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') - end - - if name.nil? - raise Appwrite::Exception.new('Missing required parameter: "name"') - end - - if scopes.nil? - raise Appwrite::Exception.new('Missing required parameter: "scopes"') - end - - api_params = { - keyId: key_id, - name: name, - scopes: scopes, - expire: expire, - } - - api_headers = { - "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::Key - ) - end - - # Get a key by its unique ID. This endpoint returns details about a specific - # API key in your organization including its scopes. - # - # @param [String] key_id Key unique ID. - # - # @return [Key] - def get_key( - key_id: - ) - api_path = '/organization/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') - end + api_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) api_params = {} - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), - "accept": 'application/json', - } - - @client.call( - method: 'GET', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::Key - ) - end - - # Update a key by its unique ID. Use this endpoint to update the name, - # scopes, or expiration time of an API key. - # - # @param [String] key_id Key unique ID. - # @param [String] name Key name. Max length: 128 chars. - # @param [Array] scopes Key scopes list. Maximum of 200 scopes are allowed. - # @param [String] expire Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - # - # @return [Key] - def update_key( - key_id:, - name:, - scopes:, - expire: nil - ) - api_path = '/organization/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') - end - - if name.nil? - raise Appwrite::Exception.new('Missing required parameter: "name"') - end - - if scopes.nil? - raise Appwrite::Exception.new('Missing required parameter: "scopes"') - end - - api_params = { - name: name, - scopes: scopes, - expire: expire, - } - api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } - @client.call( - method: 'PUT', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::Key - ) - end - - # Delete a key by its unique ID. Once deleted, the key can no longer be used - # to authenticate API calls. - # - # @param [String] key_id Key unique ID. - # - # @return [] - def delete_key( - key_id: - ) - api_path = '/organization/keys/{keyId}' - .gsub('{keyId}', key_id) - - 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', - } - @client.call( method: 'DELETE', path: api_path, @@ -508,12 +314,12 @@ def create_membership( url: nil, name: nil ) - api_path = '/organization/memberships' - if roles.nil? raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/organization/memberships' + api_params = { email: email, userId: user_id, @@ -546,13 +352,13 @@ def create_membership( def get_membership( membership_id: ) - api_path = '/organization/memberships/{membershipId}' - .gsub('{membershipId}', membership_id) - - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/organization/memberships/{membershipId}' + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { @@ -579,10 +385,7 @@ def update_membership( membership_id:, roles: ) - api_path = '/organization/memberships/{membershipId}' - .gsub('{membershipId}', membership_id) - - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end @@ -590,6 +393,9 @@ def update_membership( raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/organization/memberships/{membershipId}' + .gsub('{membershipId}', membership_id) + api_params = { roles: roles, } @@ -619,18 +425,19 @@ def update_membership( def delete_membership( membership_id: ) - api_path = '/organization/memberships/{membershipId}' - .gsub('{membershipId}', membership_id) - - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/organization/memberships/{membershipId}' + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -688,8 +495,6 @@ def create_project( name:, region: nil ) - api_path = '/organization/projects' - if project_id.nil? raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -698,6 +503,8 @@ def create_project( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/organization/projects' + api_params = { projectId: project_id, name: name, @@ -727,17 +534,18 @@ def create_project( def get_project( project_id: ) - api_path = '/organization/projects/{projectId}' - .gsub('{projectId}', project_id) - - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end + api_path = '/organization/projects/{projectId}' + .gsub('{projectId}', project_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', } @client.call( @@ -759,10 +567,7 @@ def update_project( project_id:, name: ) - api_path = '/organization/projects/{projectId}' - .gsub('{projectId}', project_id) - - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -770,6 +575,9 @@ def update_project( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/organization/projects/{projectId}' + .gsub('{projectId}', project_id) + api_params = { name: name, } @@ -797,18 +605,19 @@ def update_project( def delete_project( project_id: ) - api_path = '/organization/projects/{projectId}' - .gsub('{projectId}', project_id) - - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end + api_path = '/organization/projects/{projectId}' + .gsub('{projectId}', project_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -831,7 +640,7 @@ def list_project_keys( queries: nil, total: nil ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -874,7 +683,7 @@ def create_ephemeral_project_key( scopes:, duration: ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -919,11 +728,11 @@ def get_project_key( project_id:, key_id: ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end @@ -964,11 +773,11 @@ def update_project_key( scopes:, expire: nil ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end @@ -1016,11 +825,11 @@ def delete_project_key( project_id:, key_id: ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end diff --git a/lib/appwrite/services/postgresql.rb b/lib/appwrite/services/postgresql.rb index cd67e74e..24c0ce2d 100644 --- a/lib/appwrite/services/postgresql.rb +++ b/lib/appwrite/services/postgresql.rb @@ -50,7 +50,7 @@ def list( # @param [Integer] pitr_retention_days Number of days to retain PITR data. # @param [] storage_autoscaling Enable automatic storage expansion when usage exceeds threshold. # @param [Integer] storage_autoscaling_threshold_percent Storage usage percentage (50-95) that triggers automatic expansion. - # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. 0 means no limit. + # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. # # @return [DedicatedDatabase] def create( @@ -69,8 +69,6 @@ def create( storage_autoscaling_threshold_percent: nil, storage_autoscaling_max_gb: nil ) - api_path = '/postgresql' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -79,6 +77,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/postgresql' + api_params = { databaseId: database_id, name: name, @@ -112,8 +112,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -145,13 +145,13 @@ def list_specifications() def get( database_id: ) - api_path = '/postgresql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update( sql_api_max_bytes: nil, sql_api_timeout_seconds: nil ) - api_path = '/postgresql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, status: status, @@ -275,13 +275,13 @@ def update( def delete( database_id: ) - api_path = '/postgresql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -309,13 +309,13 @@ def list_backups( database_id:, queries: nil ) - api_path = '/postgresql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -345,13 +345,13 @@ def create_backup( database_id:, type: nil ) - api_path = '/postgresql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { type: type, } @@ -381,13 +381,13 @@ def list_backup_policies( database_id:, queries: nil ) - api_path = '/postgresql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -426,10 +426,7 @@ def create_backup_policy( type: nil, enabled: nil ) - api_path = '/postgresql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -449,6 +446,9 @@ def create_backup_policy( raise Appwrite::Exception.new('Missing required parameter: "retention"') end + api_path = '/postgresql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { policyId: policy_id, name: name, @@ -483,18 +483,18 @@ def get_backup_policy( database_id:, policy_id: ) - api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -529,18 +529,18 @@ def update_backup_policy( retention: nil, enabled: nil ) - api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = { name: name, schedule: schedule, @@ -574,18 +574,18 @@ def delete_backup_policy( database_id:, policy_id: ) - api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -626,10 +626,7 @@ def update_backup_storage( prefix: nil, endpoint: nil ) - api_path = '/postgresql/{databaseId}/backups/storage' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -649,6 +646,9 @@ def update_backup_storage( raise Appwrite::Exception.new('Missing required parameter: "secretKey"') end + api_path = '/postgresql/{databaseId}/backups/storage' + .gsub('{databaseId}', database_id) + api_params = { provider: provider, bucket: bucket, @@ -685,18 +685,18 @@ def get_backup( database_id:, backup_id: ) - api_path = '/postgresql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/postgresql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -724,18 +724,18 @@ def delete_backup( database_id:, backup_id: ) - api_path = '/postgresql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/postgresql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -761,13 +761,13 @@ def delete_backup( def list_branches( database_id: ) - api_path = '/postgresql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -800,13 +800,13 @@ def create_branch( branch_id: nil, ttl: nil ) - api_path = '/postgresql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = { branchId: branch_id, ttl: ttl, @@ -839,18 +839,18 @@ def delete_branch( database_id:, branch_id: ) - api_path = '/postgresql/{databaseId}/branches/{branchId}' - .gsub('{databaseId}', database_id) - .gsub('{branchId}', branch_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if branch_id.nil? + if branch_id.nil? || branch_id == '' raise Appwrite::Exception.new('Missing required parameter: "branchId"') end + api_path = '/postgresql/{databaseId}/branches/{branchId}' + .gsub('{databaseId}', database_id) + .gsub('{branchId}', branch_id) + api_params = {} api_headers = { @@ -879,13 +879,13 @@ def delete_branch( def update_credentials( database_id: ) - api_path = '/postgresql/{databaseId}/credentials' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/credentials' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -912,11 +912,15 @@ def update_credentials( # without a per-query cloud round-trip. The statement type must be on the # database's configured allow-list. Use bound parameters for any # user-supplied values — the API does not interpolate raw strings. + # Long-running statements (for example CREATE INDEX) can outlive the HTTP + # request: if the request ends before a result is returned, check the + # database before retrying, and prefer a direct connection for work that may + # take minutes. # # @param [String] database_id Database ID. # @param [String] sql SQL statement to execute. Exactly one statement per request. # @param [Hash] bindings Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. - # @param [Integer] timeout_seconds Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. + # @param [Integer] timeout_seconds Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. # # @return [DedicatedDatabaseExecution] def create_execution( @@ -925,10 +929,7 @@ def create_execution( bindings: nil, timeout_seconds: nil ) - api_path = '/postgresql/{databaseId}/executions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -936,6 +937,9 @@ def create_execution( raise Appwrite::Exception.new('Missing required parameter: "sql"') end + api_path = '/postgresql/{databaseId}/executions' + .gsub('{databaseId}', database_id) + api_params = { sql: sql, bindings: bindings, @@ -965,13 +969,13 @@ def create_execution( def list_extensions( database_id: ) - api_path = '/postgresql/{databaseId}/extensions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/extensions' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -999,10 +1003,7 @@ def create_extension( database_id:, name: ) - api_path = '/postgresql/{databaseId}/extensions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1010,6 +1011,9 @@ def create_extension( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/postgresql/{databaseId}/extensions' + .gsub('{databaseId}', database_id) + api_params = { name: name, } @@ -1040,18 +1044,18 @@ def delete_extension( database_id:, extension_name: ) - api_path = '/postgresql/{databaseId}/extensions/{extensionName}' - .gsub('{databaseId}', database_id) - .gsub('{extensionName}', extension_name) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if extension_name.nil? + if extension_name.nil? || extension_name == '' raise Appwrite::Exception.new('Missing required parameter: "extensionName"') end + api_path = '/postgresql/{databaseId}/extensions/{extensionName}' + .gsub('{databaseId}', database_id) + .gsub('{extensionName}', extension_name) + api_params = {} api_headers = { @@ -1087,13 +1091,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/postgresql/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1127,10 +1131,7 @@ def update_maintenance( day:, hour_utc: ) - api_path = '/postgresql/{databaseId}/maintenance' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1142,6 +1143,9 @@ def update_maintenance( raise Appwrite::Exception.new('Missing required parameter: "hourUtc"') end + api_path = '/postgresql/{databaseId}/maintenance' + .gsub('{databaseId}', database_id) + api_params = { day: day, hourUtc: hour_utc, @@ -1177,10 +1181,7 @@ def create_migration( target_type:, specification: nil ) - api_path = '/postgresql/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1188,6 +1189,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "targetType"') end + api_path = '/postgresql/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { targetType: target_type, specification: specification, @@ -1225,13 +1229,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/postgresql/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1261,13 +1265,13 @@ def list_operations( def get_pitr( database_id: ) - api_path = '/postgresql/{databaseId}/pitr' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/pitr' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1293,13 +1297,13 @@ def get_pitr( def get_pooler( database_id: ) - api_path = '/postgresql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1323,7 +1327,7 @@ def get_pooler( # @param [String] mode Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. # @param [Integer] max_connections Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. # @param [Integer] default_pool_size Default pool size per user. - # @param [] read_write_splitting Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + # @param [] read_write_splitting Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. # @param [String] pooler_cpu_request Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). # @param [String] pooler_cpu_limit Pooler sidecar CPU limit override (Kubernetes quantity, e.g. "500m" or "1"). Leave null for the proportional default (10% of DB CPU, floor 200m). Changing this field rolls the database pod. # @param [String] pooler_memory_request Pooler sidecar memory request override (Kubernetes quantity, e.g. "128Mi" or "1Gi"). Leave null for the proportional default (7.5% of DB memory, floor 64Mi). @@ -1341,13 +1345,13 @@ def update_pooler( pooler_memory_request: nil, pooler_memory_limit: nil ) - api_path = '/postgresql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = { mode: mode, maxConnections: max_connections, @@ -1383,13 +1387,13 @@ def update_pooler( def get_replicas( database_id: ) - api_path = '/postgresql/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1423,13 +1427,13 @@ def list_restorations( limit: nil, offset: nil ) - api_path = '/postgresql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { status: status, type: type, @@ -1456,11 +1460,25 @@ def list_restorations( # an ISO 8601 datetime. PITR requires the database to have PITR enabled and # is only available for enterprise databases. # + # By default the backup is replayed over the database it was taken from. Pass + # `restoreMode` as `clone` to recover it onto a second workload beside this + # database instead: this database keeps serving its own data while the clone + # is filled, and the switch happens as soon as the clone is ready, on the + # endpoint and credentials it already had. Pass `autoPromote` as false to + # hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + # to recover onto a separate database with its own endpoint, either one you + # name with `targetDatabaseId` or one provisioned as a copy of this + # database's engine, version, specification and replicas. Neither mode is + # available for a point-in-time recovery or an incremental backup. + # # @param [String] database_id Database ID. # @param [String] type Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. # @param [String] backup_id Backup ID to restore from (required for backup type). - # @param [String] target_database_id Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + # @param [String] target_database_id Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. # @param [String] target_time Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. + # @param [String] restore_mode Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + # @param [String] target_name Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + # @param [] auto_promote Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. # # @return [DedicatedDatabaseRestoration] def create_restoration( @@ -1468,20 +1486,26 @@ def create_restoration( type: nil, backup_id: nil, target_database_id: nil, - target_time: nil + target_time: nil, + restore_mode: nil, + target_name: nil, + auto_promote: nil ) - api_path = '/postgresql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { type: type, backupId: backup_id, targetDatabaseId: target_database_id, targetTime: target_time, + restoreMode: restore_mode, + targetName: target_name, + autoPromote: auto_promote, } api_headers = { @@ -1510,27 +1534,71 @@ def get_restoration( database_id:, restoration_id: ) + if database_id.nil? || database_id == '' + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if restoration_id.nil? || restoration_id == '' + raise Appwrite::Exception.new('Missing required parameter: "restorationId"') + end + api_path = '/postgresql/{databaseId}/restorations/{restorationId}' .gsub('{databaseId}', database_id) .gsub('{restorationId}', restoration_id) - if database_id.nil? + 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::DedicatedDatabaseRestoration + ) + end + + # Switch the database over to the clone a restoration recovered. The database + # keeps + # its endpoint and credentials; clients reconnect once. Writes made after the + # recovery point are discarded, and the side being replaced is retained + # briefly so + # the switch can be reversed. + # + # @param [String] database_id Database ID. + # @param [String] restoration_id Restoration ID. + # + # @return [DedicatedDatabaseRestoration] + def promote_restoration( + database_id:, + restoration_id: + ) + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/postgresql/{databaseId}/restorations/{restorationId}/promotions' + .gsub('{databaseId}', database_id) + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', "accept": 'application/json', } @client.call( - method: 'GET', + method: 'POST', path: api_path, headers: api_headers, params: api_params, @@ -1548,13 +1616,13 @@ def get_restoration( def get_status( database_id: ) - api_path = '/postgresql/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1582,10 +1650,7 @@ def create_upgrade( database_id:, target_version: ) - api_path = '/postgresql/{databaseId}/upgrades' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1593,6 +1658,9 @@ def create_upgrade( raise Appwrite::Exception.new('Missing required parameter: "targetVersion"') end + api_path = '/postgresql/{databaseId}/upgrades' + .gsub('{databaseId}', database_id) + api_params = { targetVersion: target_version, } diff --git a/lib/appwrite/services/presences.rb b/lib/appwrite/services/presences.rb index 01a022ed..a90a17d2 100644 --- a/lib/appwrite/services/presences.rb +++ b/lib/appwrite/services/presences.rb @@ -51,13 +51,13 @@ def list( def get( presence_id: ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = {} api_headers = { @@ -93,10 +93,7 @@ def upsert( expires_at: nil, metadata: nil ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end @@ -108,6 +105,9 @@ def upsert( raise Appwrite::Exception.new('Missing required parameter: "status"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = { userId: user_id, status: status, @@ -153,10 +153,7 @@ def update( permissions: nil, purge: nil ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end @@ -164,6 +161,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = { userId: user_id, status: status, @@ -197,18 +197,19 @@ def update( def delete( presence_id: ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/project.rb b/lib/appwrite/services/project.rb index 21ff2eb5..e5bc96b9 100644 --- a/lib/appwrite/services/project.rb +++ b/lib/appwrite/services/project.rb @@ -17,6 +17,7 @@ def get() api_headers = { "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', } @client.call( @@ -40,6 +41,7 @@ def delete() api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -53,7 +55,7 @@ def delete() # Update properties of a specific auth method. Use this endpoint to enable or # disable a method in your project. # - # @param [ProjectAuthMethodId] method_id Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone + # @param [ProjectAuthMethodId] method_id Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey # @param [] enabled Auth method status. # # @return [Project] @@ -61,9 +63,6 @@ def update_auth_method( method_id:, enabled: ) - api_path = '/project/auth-methods/{methodId}' - .gsub('{methodId}', method_id) - if method_id.nil? raise Appwrite::Exception.new('Missing required parameter: "methodId"') end @@ -72,6 +71,9 @@ def update_auth_method( raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/auth-methods/{methodId}' + .gsub('{methodId}', method_id) + api_params = { enabled: enabled, } @@ -173,7 +175,7 @@ def create_environment( def get_environment( environment_id: ) - if environment_id.nil? + if environment_id.nil? || environment_id == '' raise Appwrite::Exception.new('Missing required parameter: "environmentId"') end @@ -206,7 +208,7 @@ def update_environment( environment_id:, name: ) - if environment_id.nil? + if environment_id.nil? || environment_id == '' raise Appwrite::Exception.new('Missing required parameter: "environmentId"') end @@ -244,7 +246,7 @@ def update_environment( def delete_environment( environment_id: ) - if environment_id.nil? + if environment_id.nil? || environment_id == '' raise Appwrite::Exception.new('Missing required parameter: "environmentId"') end @@ -312,8 +314,6 @@ def create_ephemeral_key( scopes:, duration: ) - api_path = '/project/keys/ephemeral' - if scopes.nil? raise Appwrite::Exception.new('Missing required parameter: "scopes"') end @@ -322,6 +322,8 @@ def create_ephemeral_key( raise Appwrite::Exception.new('Missing required parameter: "duration"') end + api_path = '/project/keys/ephemeral' + api_params = { scopes: scopes, duration: duration, @@ -350,13 +352,13 @@ def create_ephemeral_key( def get_key( key_id: ) - api_path = '/project/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/project/keys/{keyId}' + .gsub('{keyId}', key_id) + api_params = {} api_headers = { @@ -388,10 +390,7 @@ def update_key( scopes:, expire: nil ) - api_path = '/project/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end @@ -403,6 +402,9 @@ def update_key( raise Appwrite::Exception.new('Missing required parameter: "scopes"') end + api_path = '/project/keys/{keyId}' + .gsub('{keyId}', key_id) + api_params = { name: name, scopes: scopes, @@ -433,18 +435,19 @@ def update_key( def delete_key( key_id: ) - api_path = '/project/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/project/keys/{keyId}' + .gsub('{keyId}', key_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -464,12 +467,12 @@ def delete_key( def update_labels( labels: ) - api_path = '/project/labels' - if labels.nil? raise Appwrite::Exception.new('Missing required parameter: "labels"') end + api_path = '/project/labels' + api_params = { labels: labels, } @@ -532,8 +535,6 @@ def create_mock_phone( number:, otp: ) - api_path = '/project/mock-phones' - if number.nil? raise Appwrite::Exception.new('Missing required parameter: "number"') end @@ -542,6 +543,8 @@ def create_mock_phone( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/project/mock-phones' + api_params = { number: number, otp: otp, @@ -571,13 +574,13 @@ def create_mock_phone( def get_mock_phone( number: ) - api_path = '/project/mock-phones/{number}' - .gsub('{number}', number) - - if number.nil? + if number.nil? || number == '' raise Appwrite::Exception.new('Missing required parameter: "number"') end + api_path = '/project/mock-phones/{number}' + .gsub('{number}', number) + api_params = {} api_headers = { @@ -605,10 +608,7 @@ def update_mock_phone( number:, otp: ) - api_path = '/project/mock-phones/{number}' - .gsub('{number}', number) - - if number.nil? + if number.nil? || number == '' raise Appwrite::Exception.new('Missing required parameter: "number"') end @@ -616,6 +616,9 @@ def update_mock_phone( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/project/mock-phones/{number}' + .gsub('{number}', number) + api_params = { otp: otp, } @@ -644,18 +647,19 @@ def update_mock_phone( def delete_mock_phone( number: ) - api_path = '/project/mock-phones/{number}' - .gsub('{number}', number) - - if number.nil? + if number.nil? || number == '' raise Appwrite::Exception.new('Missing required parameter: "number"') end + api_path = '/project/mock-phones/{number}' + .gsub('{number}', number) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -737,8 +741,6 @@ def update_o_auth2_server( default_scopes: nil, installation_scopes: nil ) - api_path = '/project/oauth2-server' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end @@ -747,6 +749,8 @@ def update_o_auth2_server( raise Appwrite::Exception.new('Missing required parameter: "authorizationUrl"') end + api_path = '/project/oauth2-server' + api_params = { enabled: enabled, authorizationUrl: authorization_url, @@ -1597,23 +1601,23 @@ def update_o_auth2_hugging_face( # # @param [String] client_id 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de # @param [String] client_secret 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled - # @param [Array] prompt Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # @param [Array] prompt Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. # # @return [OAuth2Kakao] def update_o_auth2_kakao( client_id: nil, client_secret: nil, - prompt: nil, - enabled: nil + enabled: nil, + prompt: nil ) api_path = '/project/oauth2/kakao' api_params = { clientId: client_id, clientSecret: client_secret, - prompt: prompt, enabled: enabled, + prompt: prompt, } api_headers = { @@ -2595,13 +2599,13 @@ def update_o_auth2_zoom( def get_o_auth2_provider( provider_id: ) - api_path = '/project/oauth2/{providerId}' - .gsub('{providerId}', provider_id) - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/project/oauth2/{providerId}' + .gsub('{providerId}', provider_id) + api_params = {} api_headers = { @@ -2901,8 +2905,6 @@ def create_android_platform( application_id:, fingerprints: nil ) - api_path = '/project/platforms/android' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -2915,6 +2917,8 @@ def create_android_platform( raise Appwrite::Exception.new('Missing required parameter: "applicationId"') end + api_path = '/project/platforms/android' + api_params = { platformId: platform_id, name: name, @@ -2938,7 +2942,7 @@ def create_android_platform( end # Update an Android platform by its unique ID. Use this endpoint to update - # the platform's name or application ID. + # the platform's name, application ID or signing certificate fingerprints. # # @param [String] platform_id Platform ID. # @param [String] name Platform name. Max length: 128 chars. @@ -2952,10 +2956,7 @@ def update_android_platform( application_id:, fingerprints: nil ) - api_path = '/project/platforms/android/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -2967,6 +2968,9 @@ def update_android_platform( raise Appwrite::Exception.new('Missing required parameter: "applicationId"') end + api_path = '/project/platforms/android/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, applicationId: application_id, @@ -3002,8 +3006,6 @@ def create_apple_platform( name:, bundle_identifier: ) - api_path = '/project/platforms/apple' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3016,6 +3018,8 @@ def create_apple_platform( raise Appwrite::Exception.new('Missing required parameter: "bundleIdentifier"') end + api_path = '/project/platforms/apple' + api_params = { platformId: platform_id, name: name, @@ -3050,10 +3054,7 @@ def update_apple_platform( name:, bundle_identifier: ) - api_path = '/project/platforms/apple/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3065,6 +3066,9 @@ def update_apple_platform( raise Appwrite::Exception.new('Missing required parameter: "bundleIdentifier"') end + api_path = '/project/platforms/apple/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, bundleIdentifier: bundle_identifier, @@ -3099,8 +3103,6 @@ def create_linux_platform( name:, package_name: ) - api_path = '/project/platforms/linux' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3113,6 +3115,8 @@ def create_linux_platform( raise Appwrite::Exception.new('Missing required parameter: "packageName"') end + api_path = '/project/platforms/linux' + api_params = { platformId: platform_id, name: name, @@ -3147,10 +3151,7 @@ def update_linux_platform( name:, package_name: ) - api_path = '/project/platforms/linux/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3162,6 +3163,9 @@ def update_linux_platform( raise Appwrite::Exception.new('Missing required parameter: "packageName"') end + api_path = '/project/platforms/linux/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, packageName: package_name, @@ -3196,8 +3200,6 @@ def create_web_platform( name:, hostname: ) - api_path = '/project/platforms/web' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3210,6 +3212,8 @@ def create_web_platform( raise Appwrite::Exception.new('Missing required parameter: "hostname"') end + api_path = '/project/platforms/web' + api_params = { platformId: platform_id, name: name, @@ -3244,10 +3248,7 @@ def update_web_platform( name:, hostname: ) - api_path = '/project/platforms/web/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3259,6 +3260,9 @@ def update_web_platform( raise Appwrite::Exception.new('Missing required parameter: "hostname"') end + api_path = '/project/platforms/web/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, hostname: hostname, @@ -3293,8 +3297,6 @@ def create_windows_platform( name:, package_identifier_name: ) - api_path = '/project/platforms/windows' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3307,6 +3309,8 @@ def create_windows_platform( raise Appwrite::Exception.new('Missing required parameter: "packageIdentifierName"') end + api_path = '/project/platforms/windows' + api_params = { platformId: platform_id, name: name, @@ -3341,10 +3345,7 @@ def update_windows_platform( name:, package_identifier_name: ) - api_path = '/project/platforms/windows/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3356,6 +3357,9 @@ def update_windows_platform( raise Appwrite::Exception.new('Missing required parameter: "packageIdentifierName"') end + api_path = '/project/platforms/windows/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, packageIdentifierName: package_identifier_name, @@ -3385,13 +3389,13 @@ def update_windows_platform( def get_platform( platform_id: ) - api_path = '/project/platforms/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end + api_path = '/project/platforms/{platformId}' + .gsub('{platformId}', platform_id) + api_params = {} api_headers = { @@ -3447,18 +3451,19 @@ def get_platform( def delete_platform( platform_id: ) - api_path = '/project/platforms/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end + api_path = '/project/platforms/{platformId}' + .gsub('{platformId}', platform_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3509,12 +3514,12 @@ def list_policies( def update_deny_aliased_email_policy( enabled: ) - api_path = '/project/policies/deny-aliased-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-aliased-email' + api_params = { enabled: enabled, } @@ -3543,12 +3548,12 @@ def update_deny_aliased_email_policy( def update_deny_corporate_email_policy( enabled: ) - api_path = '/project/policies/deny-corporate-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-corporate-email' + api_params = { enabled: enabled, } @@ -3577,12 +3582,12 @@ def update_deny_corporate_email_policy( def update_deny_disposable_email_policy( enabled: ) - api_path = '/project/policies/deny-disposable-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-disposable-email' + api_params = { enabled: enabled, } @@ -3611,12 +3616,12 @@ def update_deny_disposable_email_policy( def update_deny_free_email_policy( enabled: ) - api_path = '/project/policies/deny-free-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-free-email' + api_params = { enabled: enabled, } @@ -3772,12 +3777,12 @@ def update_passkey_policy( def update_password_dictionary_policy( enabled: ) - api_path = '/project/policies/password-dictionary' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/password-dictionary' + api_params = { enabled: enabled, } @@ -3813,12 +3818,12 @@ def update_password_dictionary_policy( def update_password_history_policy( total: ) - api_path = '/project/policies/password-history' - if total.nil? raise Appwrite::Exception.new('Missing required parameter: "total"') end + api_path = '/project/policies/password-history' + api_params = { total: total, } @@ -3849,12 +3854,12 @@ def update_password_history_policy( def update_password_personal_data_policy( enabled: ) - api_path = '/project/policies/password-personal-data' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/password-personal-data' + api_params = { enabled: enabled, } @@ -4003,12 +4008,12 @@ def update_password_strength_policy( def update_session_alert_policy( enabled: ) - api_path = '/project/policies/session-alert' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/session-alert' + api_params = { enabled: enabled, } @@ -4037,12 +4042,12 @@ def update_session_alert_policy( def update_session_duration_policy( duration: ) - api_path = '/project/policies/session-duration' - if duration.nil? raise Appwrite::Exception.new('Missing required parameter: "duration"') end + api_path = '/project/policies/session-duration' + api_params = { duration: duration, } @@ -4072,12 +4077,12 @@ def update_session_duration_policy( def update_session_invalidation_policy( enabled: ) - api_path = '/project/policies/session-invalidation' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/session-invalidation' + api_params = { enabled: enabled, } @@ -4106,12 +4111,12 @@ def update_session_invalidation_policy( def update_session_limit_policy( total: ) - api_path = '/project/policies/session-limit' - if total.nil? raise Appwrite::Exception.new('Missing required parameter: "total"') end + api_path = '/project/policies/session-limit' + api_params = { total: total, } @@ -4141,12 +4146,12 @@ def update_session_limit_policy( def update_user_limit_policy( total: ) - api_path = '/project/policies/user-limit' - if total.nil? raise Appwrite::Exception.new('Missing required parameter: "total"') end + api_path = '/project/policies/user-limit' + api_params = { total: total, } @@ -4169,19 +4174,19 @@ def update_user_limit_policy( # Get a policy by its unique ID. This endpoint returns the current # configuration for the requested project policy. # - # @param [ProjectPolicyId] policy_id Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + # @param [ProjectPolicyId] policy_id Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. # # @return [PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordStrength, PolicyPasswordPersonalData, PolicyPasswordPwned, PolicyPasswordRotation, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy, PolicyMfaFactors, PolicyDenyAliasedEmail, PolicyDenyDisposableEmail, PolicyDenyFreeEmail, PolicyDenyCorporateEmail, PolicyPasskey] def get_policy( policy_id: ) - api_path = '/project/policies/{policyId}' - .gsub('{policyId}', policy_id) - if policy_id.nil? raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/project/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -4304,9 +4309,6 @@ def update_protocol( protocol_id:, enabled: ) - api_path = '/project/protocols/{protocolId}' - .gsub('{protocolId}', protocol_id) - if protocol_id.nil? raise Appwrite::Exception.new('Missing required parameter: "protocolId"') end @@ -4315,6 +4317,9 @@ def update_protocol( raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/protocols/{protocolId}' + .gsub('{protocolId}', protocol_id) + api_params = { enabled: enabled, } @@ -4345,9 +4350,6 @@ def update_service( service_id:, enabled: ) - api_path = '/project/services/{serviceId}' - .gsub('{serviceId}', service_id) - if service_id.nil? raise Appwrite::Exception.new('Missing required parameter: "serviceId"') end @@ -4356,6 +4358,9 @@ def update_service( raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/services/{serviceId}' + .gsub('{serviceId}', service_id) + api_params = { enabled: enabled, } @@ -4441,12 +4446,12 @@ def update_smtp( def create_smtp_test( emails: ) - api_path = '/project/smtp/tests' - if emails.nil? raise Appwrite::Exception.new('Missing required parameter: "emails"') end + api_path = '/project/smtp/tests' + api_params = { emails: emails, } @@ -4454,6 +4459,7 @@ def create_smtp_test( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -4500,7 +4506,7 @@ def list_email_templates( # Update a custom email template for the specified locale and type. Use this # endpoint to modify the content of your email templates. # - # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery # @param [ProjectEmailTemplateLocale] locale Custom email template locale. If left empty, the fallback locale (en) will be used. # @param [String] subject Subject of the email template. Can be up to 255 characters. # @param [String] message Plain or HTML body of the email template message. Can be up to 10MB of content. @@ -4520,12 +4526,12 @@ def update_email_template( reply_to_email: nil, reply_to_name: nil ) - api_path = '/project/templates/email' - if template_id.nil? raise Appwrite::Exception.new('Missing required parameter: "templateId"') end + api_path = '/project/templates/email' + api_params = { templateId: template_id, locale: locale, @@ -4556,7 +4562,7 @@ def update_email_template( # endpoint returns the template content, subject, and other configuration # details. # - # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery # @param [ProjectEmailTemplateLocale] locale Custom email template locale. If left empty, the fallback locale (en) will be used. # # @return [EmailTemplate] @@ -4564,13 +4570,13 @@ def get_email_template( template_id:, locale: nil ) - api_path = '/project/templates/email/{templateId}' - .gsub('{templateId}', template_id) - if template_id.nil? raise Appwrite::Exception.new('Missing required parameter: "templateId"') end + api_path = '/project/templates/email/{templateId}' + .gsub('{templateId}', template_id) + api_params = { locale: locale, } @@ -4635,8 +4641,6 @@ def create_variable( value:, secret: nil ) - api_path = '/project/variables' - if variable_id.nil? raise Appwrite::Exception.new('Missing required parameter: "variableId"') end @@ -4649,6 +4653,8 @@ def create_variable( raise Appwrite::Exception.new('Missing required parameter: "value"') end + api_path = '/project/variables' + api_params = { variableId: variable_id, key: key, @@ -4679,13 +4685,13 @@ def create_variable( def get_variable( variable_id: ) - api_path = '/project/variables/{variableId}' - .gsub('{variableId}', variable_id) - - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/project/variables/{variableId}' + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { @@ -4716,13 +4722,13 @@ def update_variable( value: nil, secret: nil ) - api_path = '/project/variables/{variableId}' - .gsub('{variableId}', variable_id) - - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/project/variables/{variableId}' + .gsub('{variableId}', variable_id) + api_params = { key: key, value: value, @@ -4752,18 +4758,19 @@ def update_variable( def delete_variable( variable_id: ) - api_path = '/project/variables/{variableId}' - .gsub('{variableId}', variable_id) - - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/project/variables/{variableId}' + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/proxy.rb b/lib/appwrite/services/proxy.rb index 48d11c6d..b84b9b2d 100644 --- a/lib/appwrite/services/proxy.rb +++ b/lib/appwrite/services/proxy.rb @@ -12,6 +12,8 @@ def initialize(client) # Depending on type, the invalidation purges a single cache tag, a single URL # path, or all cached content for the domain. # + # Domains that route to a function do not support cache invalidation. + # # @param [String] domain Domain name. # @param [InvalidationType] type Type of reference passed. Allowed values are: tag, path, all # @param [String] reference Reference to invalidate. Depending on type this can be: cache tag name (up to 128 characters), URL path (up to 2048 characters). Not required when type is all. @@ -22,8 +24,6 @@ def create_invalidation( type:, reference: nil ) - api_path = '/proxy/invalidations' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -32,6 +32,8 @@ def create_invalidation( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/proxy/invalidations' + api_params = { domain: domain, type: type, @@ -56,7 +58,7 @@ def create_invalidation( # Get a list of all the proxy rules. You can use the query params to filter # your results. # - # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch, protocol # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [ProxyRuleList] @@ -96,12 +98,12 @@ def list_rules( def create_api_rule( domain: ) - api_path = '/proxy/rules/api' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end + api_path = '/proxy/rules/api' + api_params = { domain: domain, } @@ -136,8 +138,6 @@ def create_function_rule( function_id:, branch: nil ) - api_path = '/proxy/rules/function' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -146,6 +146,8 @@ def create_function_rule( raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/proxy/rules/function' + api_params = { domain: domain, functionId: function_id, @@ -187,8 +189,6 @@ def create_redirect_rule( resource_id:, resource_type: ) - api_path = '/proxy/rules/redirect' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -209,6 +209,8 @@ def create_redirect_rule( raise Appwrite::Exception.new('Missing required parameter: "resourceType"') end + api_path = '/proxy/rules/redirect' + api_params = { domain: domain, url: url, @@ -247,8 +249,6 @@ def create_site_rule( site_id:, branch: nil ) - api_path = '/proxy/rules/site' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -257,6 +257,8 @@ def create_site_rule( raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/proxy/rules/site' + api_params = { domain: domain, siteId: site_id, @@ -278,6 +280,50 @@ def create_site_rule( ) end + # Create an SMTP ingress rule that asynchronously executes an Appwrite + # Function for incoming email. + # + # @param [String] domain Domain that receives email. + # @param [String] function_id ID of function to execute. + # @param [String] branch Name of VCS branch to deploy changes automatically. + # + # @return [ProxyRule] + def create_smtp_rule( + domain:, + function_id:, + branch: nil + ) + if domain.nil? + raise Appwrite::Exception.new('Missing required parameter: "domain"') + end + + if function_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "functionId"') + end + + api_path = '/proxy/rules/smtp' + + api_params = { + domain: domain, + functionId: function_id, + branch: branch, + } + + 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::ProxyRule + ) + end + # Get a proxy rule by its unique ID. # # @param [String] rule_id Rule ID. @@ -286,13 +332,13 @@ def create_site_rule( def get_rule( rule_id: ) - api_path = '/proxy/rules/{ruleId}' - .gsub('{ruleId}', rule_id) - - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end + api_path = '/proxy/rules/{ruleId}' + .gsub('{ruleId}', rule_id) + api_params = {} api_headers = { @@ -317,18 +363,19 @@ def get_rule( def delete_rule( rule_id: ) - api_path = '/proxy/rules/{ruleId}' - .gsub('{ruleId}', rule_id) - - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end + api_path = '/proxy/rules/{ruleId}' + .gsub('{ruleId}', rule_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -350,13 +397,13 @@ def delete_rule( def update_rule_status( rule_id: ) - api_path = '/proxy/rules/{ruleId}/status' - .gsub('{ruleId}', rule_id) - - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end + api_path = '/proxy/rules/{ruleId}/status' + .gsub('{ruleId}', rule_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/sites.rb b/lib/appwrite/services/sites.rb index 46a830f2..9a7d793e 100644 --- a/lib/appwrite/services/sites.rb +++ b/lib/appwrite/services/sites.rb @@ -95,8 +95,6 @@ def create( deployment_retention: nil, scopes: nil ) - api_path = '/sites' - if site_id.nil? raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -113,6 +111,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "buildRuntime"') end + api_path = '/sites' + api_params = { siteId: site_id, name: name, @@ -223,13 +223,13 @@ def list_specifications( def get( site_id: ) - api_path = '/sites/{siteId}' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}' + .gsub('{siteId}', site_id) + api_params = {} api_headers = { @@ -300,10 +300,7 @@ def update( deployment_retention: nil, scopes: nil ) - api_path = '/sites/{siteId}' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -315,6 +312,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "framework"') end + api_path = '/sites/{siteId}' + .gsub('{siteId}', site_id) + api_params = { name: name, framework: framework, @@ -364,18 +364,19 @@ def update( def delete( site_id: ) - api_path = '/sites/{siteId}' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}' + .gsub('{siteId}', site_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -397,10 +398,7 @@ def update_site_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployment' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -408,6 +406,9 @@ def update_site_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployment' + .gsub('{siteId}', site_id) + api_params = { deploymentId: deployment_id, } @@ -442,13 +443,13 @@ def list_deployments( search: nil, total: nil ) - api_path = '/sites/{siteId}/deployments' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}/deployments' + .gsub('{siteId}', site_id) + api_params = { queries: queries, search: search, @@ -490,10 +491,7 @@ def create_deployment( activate: nil, on_progress: nil ) - api_path = '/sites/{siteId}/deployments' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -501,6 +499,9 @@ def create_deployment( raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/sites/{siteId}/deployments' + .gsub('{siteId}', site_id) + api_params = { installCommand: install_command, buildCommand: build_command, @@ -525,6 +526,7 @@ def create_deployment( param_name: param_name, id_param_name: id_param_name, on_progress: on_progress, + method: 'POST', response_type: Models::Deployment ) end @@ -543,10 +545,7 @@ def create_duplicate_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/duplicate' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -554,6 +553,9 @@ def create_duplicate_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/duplicate' + .gsub('{siteId}', site_id) + api_params = { deploymentId: deployment_id, } @@ -597,10 +599,7 @@ def create_template_deployment( reference:, activate: nil ) - api_path = '/sites/{siteId}/deployments/template' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -624,6 +623,9 @@ def create_template_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/sites/{siteId}/deployments/template' + .gsub('{siteId}', site_id) + api_params = { repository: repository, owner: owner, @@ -664,10 +666,7 @@ def create_vcs_deployment( reference:, activate: nil ) - api_path = '/sites/{siteId}/deployments/vcs' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -679,6 +678,9 @@ def create_vcs_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/sites/{siteId}/deployments/vcs' + .gsub('{siteId}', site_id) + api_params = { type: type, reference: reference, @@ -710,18 +712,18 @@ def get_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/{deploymentId}' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -748,23 +750,24 @@ def delete_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/{deploymentId}' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -791,18 +794,18 @@ def get_deployment_download( type: nil, token: nil ) - api_path = '/sites/{siteId}/deployments/{deploymentId}/download' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}/download' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = { type: type, token: token, @@ -835,18 +838,18 @@ def update_deployment_status( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/{deploymentId}/status' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}/status' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -877,13 +880,13 @@ def list_logs( queries: nil, total: nil ) - api_path = '/sites/{siteId}/logs' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}/logs' + .gsub('{siteId}', site_id) + api_params = { queries: queries, total: total, @@ -913,18 +916,18 @@ def get_log( site_id:, log_id: ) - api_path = '/sites/{siteId}/logs/{logId}' - .gsub('{siteId}', site_id) - .gsub('{logId}', log_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if log_id.nil? + if log_id.nil? || log_id == '' raise Appwrite::Exception.new('Missing required parameter: "logId"') end + api_path = '/sites/{siteId}/logs/{logId}' + .gsub('{siteId}', site_id) + .gsub('{logId}', log_id) + api_params = {} api_headers = { @@ -951,18 +954,18 @@ def delete_log( site_id:, log_id: ) - api_path = '/sites/{siteId}/logs/{logId}' - .gsub('{siteId}', site_id) - .gsub('{logId}', log_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if log_id.nil? + if log_id.nil? || log_id == '' raise Appwrite::Exception.new('Missing required parameter: "logId"') end + api_path = '/sites/{siteId}/logs/{logId}' + .gsub('{siteId}', site_id) + .gsub('{logId}', log_id) + api_params = {} api_headers = { @@ -991,13 +994,13 @@ def list_variables( queries: nil, total: nil ) - api_path = '/sites/{siteId}/variables' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}/variables' + .gsub('{siteId}', site_id) + api_params = { queries: queries, total: total, @@ -1034,10 +1037,7 @@ def create_variable( value:, secret: nil ) - api_path = '/sites/{siteId}/variables' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -1053,6 +1053,9 @@ def create_variable( raise Appwrite::Exception.new('Missing required parameter: "value"') end + api_path = '/sites/{siteId}/variables' + .gsub('{siteId}', site_id) + api_params = { variableId: variable_id, key: key, @@ -1085,18 +1088,18 @@ def get_variable( site_id:, variable_id: ) - api_path = '/sites/{siteId}/variables/{variableId}' - .gsub('{siteId}', site_id) - .gsub('{variableId}', variable_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/sites/{siteId}/variables/{variableId}' + .gsub('{siteId}', site_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { @@ -1129,18 +1132,18 @@ def update_variable( value: nil, secret: nil ) - api_path = '/sites/{siteId}/variables/{variableId}' - .gsub('{siteId}', site_id) - .gsub('{variableId}', variable_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/sites/{siteId}/variables/{variableId}' + .gsub('{siteId}', site_id) + .gsub('{variableId}', variable_id) + api_params = { key: key, value: value, @@ -1172,23 +1175,24 @@ def delete_variable( site_id:, variable_id: ) - api_path = '/sites/{siteId}/variables/{variableId}' - .gsub('{siteId}', site_id) - .gsub('{variableId}', variable_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/sites/{siteId}/variables/{variableId}' + .gsub('{siteId}', site_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/storage.rb b/lib/appwrite/services/storage.rb index 18389d90..1938edd1 100644 --- a/lib/appwrite/services/storage.rb +++ b/lib/appwrite/services/storage.rb @@ -69,8 +69,6 @@ def create_bucket( antivirus: nil, transformations: nil ) - api_path = '/storage/buckets' - if bucket_id.nil? raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end @@ -79,6 +77,8 @@ def create_bucket( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/storage/buckets' + api_params = { bucketId: bucket_id, name: name, @@ -117,13 +117,13 @@ def create_bucket( def get_bucket( bucket_id: ) - api_path = '/storage/buckets/{bucketId}' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end + api_path = '/storage/buckets/{bucketId}' + .gsub('{bucketId}', bucket_id) + api_params = {} api_headers = { @@ -168,10 +168,7 @@ def update_bucket( antivirus: nil, transformations: nil ) - api_path = '/storage/buckets/{bucketId}' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end @@ -179,6 +176,9 @@ def update_bucket( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/storage/buckets/{bucketId}' + .gsub('{bucketId}', bucket_id) + api_params = { name: name, permissions: permissions, @@ -215,18 +215,19 @@ def update_bucket( def delete_bucket( bucket_id: ) - api_path = '/storage/buckets/{bucketId}' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end + api_path = '/storage/buckets/{bucketId}' + .gsub('{bucketId}', bucket_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -252,13 +253,13 @@ def list_files( search: nil, total: nil ) - api_path = '/storage/buckets/{bucketId}/files' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end + api_path = '/storage/buckets/{bucketId}/files' + .gsub('{bucketId}', bucket_id) + api_params = { queries: queries, search: search, @@ -313,10 +314,7 @@ def create_file( folder: nil, on_progress: nil ) - api_path = '/storage/buckets/{bucketId}/files' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end @@ -328,6 +326,9 @@ def create_file( raise Appwrite::Exception.new('Missing required parameter: "file"') end + api_path = '/storage/buckets/{bucketId}/files' + .gsub('{bucketId}', bucket_id) + api_params = { fileId: file_id, file: file, @@ -351,6 +352,7 @@ def create_file( param_name: param_name, id_param_name: id_param_name, on_progress: on_progress, + method: 'POST', response_type: Models::File ) end @@ -366,18 +368,18 @@ def get_file( bucket_id:, file_id: ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = {} api_headers = { @@ -409,18 +411,18 @@ def update_file( name: nil, permissions: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { name: name, permissions: permissions, @@ -452,23 +454,24 @@ def delete_file( bucket_id:, file_id: ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -493,18 +496,18 @@ def get_file_download( file_id:, token: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}/download' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}/download' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { token: token, } @@ -532,7 +535,7 @@ def get_file_download( # @param [String] file_id File ID # @param [Integer] width Resize preview image width, Pass an integer between 0 to 4000. # @param [Integer] height Resize preview image height, Pass an integer between 0 to 4000. - # @param [ImageGravity] gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right + # @param [ImageGravity] gravity Image crop gravity. Can be one of auto,center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right # @param [Integer] quality Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. # @param [Integer] border_width Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. # @param [String] border_color Preview image border color. Use a valid HEX color, no # is needed for prefix. @@ -560,18 +563,18 @@ def get_file_preview( output: nil, token: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}/preview' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}/preview' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { width: width, height: height, @@ -614,18 +617,18 @@ def get_file_view( file_id:, token: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}/view' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}/view' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { token: token, } diff --git a/lib/appwrite/services/tables_db.rb b/lib/appwrite/services/tables_db.rb index ef709de8..ac85cdf8 100644 --- a/lib/appwrite/services/tables_db.rb +++ b/lib/appwrite/services/tables_db.rb @@ -60,8 +60,6 @@ def create( replicas: nil, sync_mode: nil ) - api_path = '/tablesdb' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -70,6 +68,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/tablesdb' + api_params = { databaseId: database_id, name: name, @@ -95,8 +95,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -187,13 +187,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/tablesdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -222,13 +222,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/tablesdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -257,18 +257,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/tablesdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -289,13 +290,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/tablesdb/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -324,13 +325,13 @@ def create_operations( def get( database_id: ) - api_path = '/tablesdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -365,13 +366,13 @@ def update( replicas: nil, sync_mode: nil ) - api_path = '/tablesdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -404,18 +405,19 @@ def update( def delete( database_id: ) - api_path = '/tablesdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -444,13 +446,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/tablesdb/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -479,13 +481,13 @@ def create_failover( def list_migrations( database_id: ) - api_path = '/tablesdb/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -503,8 +505,13 @@ def list_migrations( end # Start migrating a serverless TablesDB database onto a dedicated MySQL - # compute. Data is copied to the target while the source stays live, with a - # brief read-only window during cutover. + # compute. Data is copied to the target while the source stays live. Reads + # continue throughout. Row writes are held for up to a few seconds while + # routing switches to the dedicated compute; a write the switch has not + # absorbed within that hold is refused with `database_migration_cutover` and + # can be retried. Schema changes (tables, columns, indexes) are refused from + # creation until the cutover completes, and resume once the migration is + # `soaking`. # # @param [String] database_id Database ID. # @param [String] specification Dedicated compute specification to provision as the migration target (e.g. s-2vcpu-4gb). The migration always targets a dedicated compute, so `serverless` is not accepted. @@ -516,10 +523,7 @@ def create_migration( specification:, auto_cutover: nil ) - api_path = '/tablesdb/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -527,6 +531,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "specification"') end + api_path = '/tablesdb/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { specification: specification, autoCutover: auto_cutover, @@ -557,18 +564,18 @@ def get_migration( database_id:, migration_id: ) - api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' - .gsub('{databaseId}', database_id) - .gsub('{migrationId}', migration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if migration_id.nil? + if migration_id.nil? || migration_id == '' raise Appwrite::Exception.new('Missing required parameter: "migrationId"') end + api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' + .gsub('{databaseId}', database_id) + .gsub('{migrationId}', migration_id) + api_params = {} api_headers = { @@ -596,18 +603,18 @@ def delete_migration( database_id:, migration_id: ) - api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' - .gsub('{databaseId}', database_id) - .gsub('{migrationId}', migration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if migration_id.nil? + if migration_id.nil? || migration_id == '' raise Appwrite::Exception.new('Missing required parameter: "migrationId"') end + api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' + .gsub('{databaseId}', database_id) + .gsub('{migrationId}', migration_id) + api_params = {} api_headers = { @@ -627,9 +634,12 @@ def delete_migration( # Cut a verified TablesDB migration over to its dedicated compute. Only # applies to a migration created with `autoCutover` disabled, which waits at # `ready_to_cutover` until this is called. The routing flip happens shortly - # after this returns, with a brief read-only window. One call buys one - # attempt: a cutover that fails a check returns the migration to `verifying` - # and parks it again, so call this once more to retry. + # after this returns. Reads are unaffected; row writes are held for up to a + # few seconds while it lands, and a write the flip has not absorbed within + # that hold is refused with `database_migration_cutover` and can be retried. + # One call buys one attempt: a cutover that fails a check returns the + # migration to `verifying` and parks it again, so call this once more to + # retry. # # @param [String] database_id Database ID. # @param [String] migration_id Migration ID. @@ -639,18 +649,18 @@ def create_cutover( database_id:, migration_id: ) - api_path = '/tablesdb/{databaseId}/migrations/{migrationId}/cutovers' - .gsub('{databaseId}', database_id) - .gsub('{migrationId}', migration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if migration_id.nil? + if migration_id.nil? || migration_id == '' raise Appwrite::Exception.new('Missing required parameter: "migrationId"') end + api_path = '/tablesdb/{databaseId}/migrations/{migrationId}/cutovers' + .gsub('{databaseId}', database_id) + .gsub('{migrationId}', migration_id) + api_params = {} api_headers = { @@ -685,13 +695,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/tablesdb/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -721,13 +731,13 @@ def list_operations( def get_replicas( database_id: ) - api_path = '/tablesdb/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -754,13 +764,13 @@ def get_replicas( def get_status( database_id: ) - api_path = '/tablesdb/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -792,13 +802,13 @@ def list_tables( search: nil, total: nil ) - api_path = '/tablesdb/{databaseId}/tables' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/tables' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -831,7 +841,7 @@ def list_tables( # @param [] row_security Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] enabled Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. # @param [Array] columns Array of column definitions to create. Each column should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. - # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). # # @return [Table] def create_table( @@ -844,10 +854,7 @@ def create_table( columns: nil, indexes: nil ) - api_path = '/tablesdb/{databaseId}/tables' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -859,6 +866,9 @@ def create_table( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/tablesdb/{databaseId}/tables' + .gsub('{databaseId}', database_id) + api_params = { tableId: table_id, name: name, @@ -895,18 +905,18 @@ def get_table( database_id:, table_id: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = {} api_headers = { @@ -943,18 +953,18 @@ def update_table( enabled: nil, purge: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { name: name, permissions: permissions, @@ -989,23 +999,24 @@ def delete_table( database_id:, table_id: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1030,18 +1041,18 @@ def list_columns( queries: nil, total: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, total: total, @@ -1085,15 +1096,11 @@ def create_big_int_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1105,6 +1112,10 @@ def create_big_int_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1153,20 +1164,15 @@ def update_big_int_column( max: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1178,6 +1184,11 @@ def update_big_int_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1220,15 +1231,11 @@ def create_boolean_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1240,6 +1247,10 @@ def create_boolean_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1281,20 +1292,15 @@ def update_boolean_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1306,6 +1312,11 @@ def update_boolean_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1345,15 +1356,11 @@ def create_datetime_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1365,6 +1372,10 @@ def create_datetime_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1406,20 +1417,15 @@ def update_datetime_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1431,6 +1437,11 @@ def update_datetime_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1471,15 +1482,11 @@ def create_email_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1491,6 +1498,10 @@ def create_email_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1533,20 +1544,15 @@ def update_email_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1558,6 +1564,11 @@ def update_email_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1600,15 +1611,11 @@ def create_enum_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1624,6 +1631,10 @@ def create_enum_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, elements: elements, @@ -1669,20 +1680,15 @@ def update_enum_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1698,6 +1704,11 @@ def update_enum_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { elements: elements, required: required, @@ -1744,15 +1755,11 @@ def create_float_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1764,6 +1771,10 @@ def create_float_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1812,20 +1823,15 @@ def update_float_column( max: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1837,6 +1843,11 @@ def update_float_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1884,15 +1895,11 @@ def create_integer_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1904,6 +1911,10 @@ def create_integer_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1952,20 +1963,15 @@ def update_integer_column( max: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1977,6 +1983,11 @@ def update_integer_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -2019,15 +2030,11 @@ def create_ip_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2039,6 +2046,10 @@ def create_ip_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2081,20 +2092,15 @@ def update_ip_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2106,6 +2112,11 @@ def update_ip_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2143,15 +2154,11 @@ def create_line_column( required:, default: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2163,6 +2170,10 @@ def create_line_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2203,20 +2214,15 @@ def update_line_column( default: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2224,6 +2230,11 @@ def update_line_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2266,15 +2277,11 @@ def create_longtext_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2286,6 +2293,10 @@ def create_longtext_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2329,20 +2340,15 @@ def update_longtext_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2354,6 +2360,11 @@ def update_longtext_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2396,15 +2407,11 @@ def create_mediumtext_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2416,6 +2423,10 @@ def create_mediumtext_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2459,20 +2470,15 @@ def update_mediumtext_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2484,6 +2490,11 @@ def update_mediumtext_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2521,15 +2532,11 @@ def create_point_column( required:, default: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2541,6 +2548,10 @@ def create_point_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2581,20 +2592,15 @@ def update_point_column( default: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2602,6 +2608,11 @@ def update_point_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2639,15 +2650,11 @@ def create_polygon_column( required:, default: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2659,6 +2666,10 @@ def create_polygon_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2699,20 +2710,15 @@ def update_polygon_column( default: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2720,6 +2726,11 @@ def update_polygon_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2765,15 +2776,11 @@ def create_relationship_column( two_way_key: nil, on_delete: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2785,6 +2792,10 @@ def create_relationship_column( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { relatedTableId: related_table_id, type: type, @@ -2809,41 +2820,92 @@ def create_relationship_column( ) end - # - # @deprecated This API has been deprecated since 1.9.0. Please use `TablesDB.createTextColumn` instead. - # - # Create a string column. + # Update relationship column. [Learn more about relationship + # columns](https://appwrite.io/docs/databases-relationships#relationship-columns). # # # @param [String] database_id Database ID. - # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] table_id Table ID. # @param [String] key Column Key. - # @param [Integer] size Column size for text columns, in number of characters. - # @param [] required Is column required? - # @param [String] default Default value for column when not provided. Cannot be set when column is required. - # @param [] array Is column an array? - # @param [] encrypt Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + # @param [RelationMutate] on_delete Delete constraint. Possible values are: cascade, restrict, setNull. + # @param [String] new_key New Column Key. # - # @return [ColumnString] - def create_string_column( + # @return [ColumnRelationship] + def update_relationship_column( database_id:, table_id:, key:, - size:, - required:, - default: nil, - array: nil, - encrypt: nil + on_delete: nil, + new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string' - .gsub('{databaseId}', database_id) + if database_id.nil? || database_id == '' + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if table_id.nil? || table_id == '' + raise Appwrite::Exception.new('Missing required parameter: "tableId"') + end + + if key.nil? || key == '' + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key}' + .gsub('{databaseId}', database_id) .gsub('{tableId}', table_id) + .gsub('{key}', key) - if database_id.nil? + api_params = { + onDelete: on_delete, + newKey: new_key, + } + + 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::ColumnRelationship + ) + end + + # + # @deprecated This API has been deprecated since 1.9.0. Please use `TablesDB.createTextColumn` instead. + # + # Create a string column. + # + # + # @param [String] database_id Database ID. + # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] key Column Key. + # @param [Integer] size Column size for text columns, in number of characters. + # @param [] required Is column required? + # @param [String] default Default value for column when not provided. Cannot be set when column is required. + # @param [] array Is column an array? + # @param [] encrypt Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + # + # @return [ColumnString] + def create_string_column( + database_id:, + table_id:, + key:, + size:, + required:, + default: nil, + array: nil, + encrypt: nil + ) + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2859,6 +2921,10 @@ def create_string_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, size: size, @@ -2908,20 +2974,15 @@ def update_string_column( size: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2933,6 +2994,11 @@ def update_string_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2976,15 +3042,11 @@ def create_text_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2996,6 +3058,10 @@ def create_text_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -3039,20 +3105,15 @@ def update_text_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3064,6 +3125,11 @@ def update_text_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3104,15 +3170,11 @@ def create_url_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3124,6 +3186,10 @@ def create_url_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -3166,20 +3232,15 @@ def update_url_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3191,6 +3252,11 @@ def update_url_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3235,15 +3301,11 @@ def create_varchar_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3259,6 +3321,10 @@ def create_varchar_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, size: size, @@ -3305,20 +3371,15 @@ def update_varchar_column( size: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3330,6 +3391,11 @@ def update_varchar_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3358,29 +3424,29 @@ def update_varchar_column( # @param [String] table_id Table ID. # @param [String] key Column Key. # - # @return [ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnString] + # @return [ColumnBoolean, ColumnBigint, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnPoint, ColumnLine, ColumnPolygon, ColumnVarchar, ColumnText, ColumnMediumtext, ColumnLongtext, ColumnString] def get_column( database_id:, table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -3424,6 +3490,11 @@ def get_column( return Models::ColumnBoolean.from(map: response) end + if response['type'] == 'bigint' + + return Models::ColumnBigint.from(map: response) + end + if response['type'] == 'integer' return Models::ColumnInteger.from(map: response) @@ -3444,6 +3515,41 @@ def get_column( return Models::ColumnRelationship.from(map: response) end + if response['type'] == 'point' + + return Models::ColumnPoint.from(map: response) + end + + if response['type'] == 'linestring' + + return Models::ColumnLine.from(map: response) + end + + if response['type'] == 'polygon' + + return Models::ColumnPolygon.from(map: response) + end + + if response['type'] == 'varchar' + + return Models::ColumnVarchar.from(map: response) + end + + if response['type'] == 'text' + + return Models::ColumnText.from(map: response) + end + + if response['type'] == 'mediumtext' + + return Models::ColumnMediumtext.from(map: response) + end + + if response['type'] == 'longtext' + + return Models::ColumnLongtext.from(map: response) + end + if response['type'] == 'string' return Models::ColumnString.from(map: response) @@ -3464,77 +3570,24 @@ def delete_column( table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end - api_params = {} - - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), - "content-type": 'application/json', - } - - @client.call( - method: 'DELETE', - path: api_path, - headers: api_headers, - params: api_params, - ) - end - - # Update relationship column. [Learn more about relationship - # columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - # - # - # @param [String] database_id Database ID. - # @param [String] table_id Table ID. - # @param [String] key Column Key. - # @param [RelationMutate] on_delete Delete constraint. Possible values are: cascade, restrict, setNull. - # @param [String] new_key New Column Key. - # - # @return [ColumnRelationship] - def update_relationship_column( - database_id:, - table_id:, - key:, - on_delete: nil, - new_key: nil - ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship' + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' .gsub('{databaseId}', database_id) .gsub('{tableId}', table_id) .gsub('{key}', key) - if database_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "databaseId"') - end - - if table_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "tableId"') - end - - if key.nil? - raise Appwrite::Exception.new('Missing required parameter: "key"') - end - - api_params = { - onDelete: on_delete, - newKey: new_key, - } + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -3543,11 +3596,10 @@ def update_relationship_column( } @client.call( - method: 'PATCH', + method: 'DELETE', path: api_path, headers: api_headers, params: api_params, - response_type: Models::ColumnRelationship ) end @@ -3565,18 +3617,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, total: total, @@ -3598,7 +3650,9 @@ def list_indexes( # Creates an index on the columns listed. Your index should include all the # columns you will query in a single request. - # Type can be `key`, `fulltext`, or `unique`. + # Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` + # is only available on PostgreSQL and lets `contains`, `startsWith`, and + # `endsWith` queries on string columns use an index. # # @param [String] database_id Database ID. # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3618,15 +3672,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3642,6 +3692,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "columns"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, type: type, @@ -3677,23 +3731,23 @@ def get_index( table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -3722,28 +3776,29 @@ def delete_index( table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3773,18 +3828,18 @@ def list_rows( total: nil, ttl: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3827,15 +3882,11 @@ def create_row( permissions: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3847,6 +3898,10 @@ def create_row( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { rowId: row_id, data: data, @@ -3886,15 +3941,11 @@ def create_rows( rows:, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3902,6 +3953,10 @@ def create_rows( raise Appwrite::Exception.new('Missing required parameter: "rows"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { rows: rows, transactionId: transaction_id, @@ -3940,15 +3995,11 @@ def upsert_rows( rows:, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3956,6 +4007,10 @@ def upsert_rows( raise Appwrite::Exception.new('Missing required parameter: "rows"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { rows: rows, transactionId: transaction_id, @@ -3993,18 +4048,18 @@ def update_rows( queries: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { data: data, queries: queries, @@ -4041,18 +4096,18 @@ def delete_rows( queries: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -4090,23 +4145,23 @@ def get_row( queries: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -4147,23 +4202,23 @@ def upsert_row( permissions: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { data: data, permissions: permissions, @@ -4204,23 +4259,23 @@ def update_row( permissions: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { data: data, permissions: permissions, @@ -4256,23 +4311,23 @@ def delete_row( row_id:, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { transactionId: transaction_id, } @@ -4280,6 +4335,7 @@ def delete_row( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -4310,28 +4366,28 @@ def decrement_row_column( min: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - .gsub('{column}', column) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end - if column.nil? + if column.nil? || column == '' raise Appwrite::Exception.new('Missing required parameter: "column"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + .gsub('{column}', column) + api_params = { value: value, min: min, @@ -4373,28 +4429,28 @@ def increment_row_column( max: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - .gsub('{column}', column) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end - if column.nil? + if column.nil? || column == '' raise Appwrite::Exception.new('Missing required parameter: "column"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + .gsub('{column}', column) + api_params = { value: value, max: max, diff --git a/lib/appwrite/services/teams.rb b/lib/appwrite/services/teams.rb index 8e19b572..71a2bc7e 100644 --- a/lib/appwrite/services/teams.rb +++ b/lib/appwrite/services/teams.rb @@ -47,7 +47,7 @@ def list( # # @param [String] team_id Team 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 Team name. Max length: 128 chars. - # @param [Array] roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + # @param [Array] roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long. # # @return [Team] def create( @@ -55,8 +55,6 @@ def create( name:, roles: nil ) - api_path = '/teams' - if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -65,6 +63,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/teams' + api_params = { teamId: team_id, name: name, @@ -94,13 +94,13 @@ def create( def get( team_id: ) - api_path = '/teams/{teamId}' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}' + .gsub('{teamId}', team_id) + api_params = {} api_headers = { @@ -127,10 +127,7 @@ def update_name( team_id:, name: ) - api_path = '/teams/{teamId}' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -138,6 +135,9 @@ def update_name( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/teams/{teamId}' + .gsub('{teamId}', team_id) + api_params = { name: name, } @@ -166,18 +166,19 @@ def update_name( def delete( team_id: ) - api_path = '/teams/{teamId}' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}' + .gsub('{teamId}', team_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -200,13 +201,13 @@ def list_installations( queries: nil, total: nil ) - api_path = '/teams/{teamId}/installations' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}/installations' + .gsub('{teamId}', team_id) + api_params = { queries: queries, total: total, @@ -241,10 +242,7 @@ def create_installation( app_id:, authorization_details: nil ) - api_path = '/teams/{teamId}/installations' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -252,6 +250,9 @@ def create_installation( raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/teams/{teamId}/installations' + .gsub('{teamId}', team_id) + api_params = { appId: app_id, authorizationDetails: authorization_details, @@ -283,18 +284,18 @@ 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? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/teams/{teamId}/installations/{installationId}' + .gsub('{teamId}', team_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -326,18 +327,18 @@ def update_installation( installation_id:, authorization_details: nil ) - api_path = '/teams/{teamId}/installations/{installationId}' - .gsub('{teamId}', team_id) - .gsub('{installationId}', installation_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/teams/{teamId}/installations/{installationId}' + .gsub('{teamId}', team_id) + .gsub('{installationId}', installation_id) + api_params = { authorizationDetails: authorization_details, } @@ -369,18 +370,18 @@ 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? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/teams/{teamId}/installations/{installationId}' + .gsub('{teamId}', team_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -413,13 +414,13 @@ def list_memberships( search: nil, total: nil ) - api_path = '/teams/{teamId}/memberships' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}/memberships' + .gsub('{teamId}', team_id) + api_params = { queries: queries, search: search, @@ -482,10 +483,7 @@ def create_membership( name: nil, membership_id: nil ) - api_path = '/teams/{teamId}/memberships' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -493,6 +491,9 @@ def create_membership( raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/teams/{teamId}/memberships' + .gsub('{teamId}', team_id) + api_params = { email: email, userId: user_id, @@ -530,18 +531,18 @@ def get_membership( team_id:, membership_id: ) - api_path = '/teams/{teamId}/memberships/{membershipId}' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/teams/{teamId}/memberships/{membershipId}' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { @@ -573,15 +574,11 @@ def update_membership( membership_id:, roles: ) - api_path = '/teams/{teamId}/memberships/{membershipId}' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end @@ -589,6 +586,10 @@ def update_membership( raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/teams/{teamId}/memberships/{membershipId}' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = { roles: roles, } @@ -620,23 +621,24 @@ def delete_membership( team_id:, membership_id: ) - api_path = '/teams/{teamId}/memberships/{membershipId}' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/teams/{teamId}/memberships/{membershipId}' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -667,15 +669,11 @@ def update_membership_status( user_id:, secret: ) - api_path = '/teams/{teamId}/memberships/{membershipId}/status' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end @@ -687,6 +685,10 @@ def update_membership_status( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/teams/{teamId}/memberships/{membershipId}/status' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = { userId: user_id, secret: secret, @@ -717,13 +719,13 @@ def update_membership_status( def get_prefs( team_id: ) - api_path = '/teams/{teamId}/prefs' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}/prefs' + .gsub('{teamId}', team_id) + api_params = {} api_headers = { @@ -752,10 +754,7 @@ def update_prefs( team_id:, prefs: ) - api_path = '/teams/{teamId}/prefs' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -763,6 +762,9 @@ def update_prefs( raise Appwrite::Exception.new('Missing required parameter: "prefs"') end + api_path = '/teams/{teamId}/prefs' + .gsub('{teamId}', team_id) + api_params = { prefs: prefs, } diff --git a/lib/appwrite/services/tokens.rb b/lib/appwrite/services/tokens.rb index 72ba9710..0e18e7b5 100644 --- a/lib/appwrite/services/tokens.rb +++ b/lib/appwrite/services/tokens.rb @@ -21,18 +21,18 @@ def list( queries: nil, total: nil ) - api_path = '/tokens/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/tokens/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { queries: queries, total: total, @@ -65,18 +65,18 @@ def create_file_token( file_id:, expire: nil ) - api_path = '/tokens/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/tokens/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { expire: expire, } @@ -104,13 +104,13 @@ def create_file_token( def get( token_id: ) - api_path = '/tokens/{tokenId}' - .gsub('{tokenId}', token_id) - - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/tokens/{tokenId}' + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { @@ -138,13 +138,13 @@ def update( token_id:, expire: nil ) - api_path = '/tokens/{tokenId}' - .gsub('{tokenId}', token_id) - - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/tokens/{tokenId}' + .gsub('{tokenId}', token_id) + api_params = { expire: expire, } @@ -172,18 +172,19 @@ def update( def delete( token_id: ) - api_path = '/tokens/{tokenId}' - .gsub('{tokenId}', token_id) - - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/tokens/{tokenId}' + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/users.rb b/lib/appwrite/services/users.rb index aefa1b2a..dbcf3e56 100644 --- a/lib/appwrite/services/users.rb +++ b/lib/appwrite/services/users.rb @@ -9,7 +9,7 @@ def initialize(client) # Get a list of all the project's users. You can use the query params to # filter your results. # - # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels, impersonator, accessedAt + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, passwordPwned, labels, impersonator, accessedAt # @param [String] search Search term to filter your list results. Max length: 256 chars. # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # @@ -57,12 +57,12 @@ def create( password: nil, name: nil ) - api_path = '/users' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users' + api_params = { userId: user_id, email: email, @@ -103,8 +103,6 @@ def create_argon2_user( password:, name: nil ) - api_path = '/users/argon2' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -117,6 +115,8 @@ def create_argon2_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/argon2' + api_params = { userId: user_id, email: email, @@ -156,8 +156,6 @@ def create_bcrypt_user( password:, name: nil ) - api_path = '/users/bcrypt' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -170,6 +168,8 @@ def create_bcrypt_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/bcrypt' + api_params = { userId: user_id, email: email, @@ -234,18 +234,19 @@ def list_identities( def delete_identity( identity_id: ) - api_path = '/users/identities/{identityId}' - .gsub('{identityId}', identity_id) - - if identity_id.nil? + if identity_id.nil? || identity_id == '' raise Appwrite::Exception.new('Missing required parameter: "identityId"') end + api_path = '/users/identities/{identityId}' + .gsub('{identityId}', identity_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -273,8 +274,6 @@ def create_md5_user( password:, name: nil ) - api_path = '/users/md5' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -287,6 +286,8 @@ def create_md5_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/md5' + api_params = { userId: user_id, email: email, @@ -326,8 +327,6 @@ def create_ph_pass_user( password:, name: nil ) - api_path = '/users/phpass' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -340,6 +339,8 @@ def create_ph_pass_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/phpass' + api_params = { userId: user_id, email: email, @@ -389,8 +390,6 @@ def create_scrypt_user( password_length:, name: nil ) - api_path = '/users/scrypt' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -423,6 +422,8 @@ def create_scrypt_user( raise Appwrite::Exception.new('Missing required parameter: "passwordLength"') end + api_path = '/users/scrypt' + api_params = { userId: user_id, email: email, @@ -474,8 +475,6 @@ def create_scrypt_modified_user( password_signer_key:, name: nil ) - api_path = '/users/scrypt-modified' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -500,6 +499,8 @@ def create_scrypt_modified_user( raise Appwrite::Exception.new('Missing required parameter: "passwordSignerKey"') end + api_path = '/users/scrypt-modified' + api_params = { userId: user_id, email: email, @@ -544,8 +545,6 @@ def create_sha_user( password_version: nil, name: nil ) - api_path = '/users/sha' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -558,6 +557,8 @@ def create_sha_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/sha' + api_params = { userId: user_id, email: email, @@ -589,13 +590,13 @@ def create_sha_user( def get( user_id: ) - api_path = '/users/{userId}' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -625,18 +626,19 @@ def get( def delete( user_id: ) - api_path = '/users/{userId}' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}' + .gsub('{userId}', user_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -657,10 +659,7 @@ def update_email( user_id:, email: ) - api_path = '/users/{userId}/email' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -668,6 +667,9 @@ def update_email( raise Appwrite::Exception.new('Missing required parameter: "email"') end + api_path = '/users/{userId}/email' + .gsub('{userId}', user_id) + api_params = { email: email, } @@ -691,7 +693,10 @@ def update_email( # impersonation headers are used, the request runs as the target user for API # behavior, while internal audit logs still attribute the action to the # original impersonator and store the impersonated target details only in - # internal audit payload data. + # internal audit payload data. Account endpoints are read-only while + # impersonating: they report the target's account, and anything that would + # change it is refused, so an impersonator cannot alter the target's + # credentials or delete their account. # # # @param [String] user_id User ID. @@ -702,10 +707,7 @@ def update_impersonator( user_id:, impersonator: ) - api_path = '/users/{userId}/impersonator' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -713,6 +715,9 @@ def update_impersonator( raise Appwrite::Exception.new('Missing required parameter: "impersonator"') end + api_path = '/users/{userId}/impersonator' + .gsub('{userId}', user_id) + api_params = { impersonator: impersonator, } @@ -746,13 +751,13 @@ def create_jwt( session_id: nil, duration: nil ) - api_path = '/users/{userId}/jwts' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/jwts' + .gsub('{userId}', user_id) + api_params = { sessionId: session_id, duration: duration, @@ -788,10 +793,7 @@ def update_labels( user_id:, labels: ) - api_path = '/users/{userId}/labels' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -799,6 +801,9 @@ def update_labels( raise Appwrite::Exception.new('Missing required parameter: "labels"') end + api_path = '/users/{userId}/labels' + .gsub('{userId}', user_id) + api_params = { labels: labels, } @@ -818,44 +823,6 @@ def update_labels( ) end - # Get the user activity logs list by its unique ID. - # - # @param [String] user_id User 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). Only supported methods are limit and offset - # @param [] total When set to false, the total count returned will be 0 and will not be calculated. - # - # @return [LogList] - def list_logs( - user_id:, - queries: nil, - total: nil - ) - api_path = '/users/{userId}/logs' - .gsub('{userId}', user_id) - - if user_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "userId"') - 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::LogList - ) - end - # Get the user membership list by its unique ID. # # @param [String] user_id User ID. @@ -870,13 +837,13 @@ def list_memberships( search: nil, total: nil ) - api_path = '/users/{userId}/memberships' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/memberships' + .gsub('{userId}', user_id) + api_params = { queries: queries, search: search, @@ -907,10 +874,7 @@ def update_mfa( user_id:, mfa: ) - api_path = '/users/{userId}/mfa' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -918,6 +882,9 @@ def update_mfa( raise Appwrite::Exception.new('Missing required parameter: "mfa"') end + api_path = '/users/{userId}/mfa' + .gsub('{userId}', user_id) + api_params = { mfa: mfa, } @@ -947,11 +914,7 @@ def delete_mfa_authenticator( user_id:, type: ) - api_path = '/users/{userId}/mfa/authenticators/{type}' - .gsub('{userId}', user_id) - .gsub('{type}', type) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -959,11 +922,16 @@ def delete_mfa_authenticator( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/users/{userId}/mfa/authenticators/{type}' + .gsub('{userId}', user_id) + .gsub('{type}', type) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -985,18 +953,18 @@ def get_mfa_challenge( user_id:, challenge_id: ) - api_path = '/users/{userId}/mfa/challenges/{challengeId}' - .gsub('{userId}', user_id) - .gsub('{challengeId}', challenge_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if challenge_id.nil? + if challenge_id.nil? || challenge_id == '' raise Appwrite::Exception.new('Missing required parameter: "challengeId"') end + api_path = '/users/{userId}/mfa/challenges/{challengeId}' + .gsub('{userId}', user_id) + .gsub('{challengeId}', challenge_id) + api_params = {} api_headers = { @@ -1021,13 +989,13 @@ def get_mfa_challenge( def list_mfa_factors( user_id: ) - api_path = '/users/{userId}/mfa/factors' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/factors' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1055,13 +1023,13 @@ def list_mfa_factors( def get_mfa_recovery_codes( user_id: ) - api_path = '/users/{userId}/mfa/recovery-codes' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/recovery-codes' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1089,13 +1057,13 @@ def get_mfa_recovery_codes( def update_mfa_recovery_codes( user_id: ) - api_path = '/users/{userId}/mfa/recovery-codes' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/recovery-codes' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1124,13 +1092,13 @@ def update_mfa_recovery_codes( def create_mfa_recovery_codes( user_id: ) - api_path = '/users/{userId}/mfa/recovery-codes' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/recovery-codes' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1158,10 +1126,7 @@ def update_name( user_id:, name: ) - api_path = '/users/{userId}/name' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1169,6 +1134,9 @@ def update_name( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/users/{userId}/name' + .gsub('{userId}', user_id) + api_params = { name: name, } @@ -1360,10 +1328,7 @@ def update_password( user_id:, password: ) - api_path = '/users/{userId}/password' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1371,6 +1336,9 @@ def update_password( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/{userId}/password' + .gsub('{userId}', user_id) + api_params = { password: password, } @@ -1400,10 +1368,7 @@ def update_phone( user_id:, number: ) - api_path = '/users/{userId}/phone' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1411,6 +1376,9 @@ def update_phone( raise Appwrite::Exception.new('Missing required parameter: "number"') end + api_path = '/users/{userId}/phone' + .gsub('{userId}', user_id) + api_params = { number: number, } @@ -1438,13 +1406,13 @@ def update_phone( def get_prefs( user_id: ) - api_path = '/users/{userId}/prefs' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/prefs' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1473,10 +1441,7 @@ def update_prefs( user_id:, prefs: ) - api_path = '/users/{userId}/prefs' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1484,6 +1449,9 @@ def update_prefs( raise Appwrite::Exception.new('Missing required parameter: "prefs"') end + api_path = '/users/{userId}/prefs' + .gsub('{userId}', user_id) + api_params = { prefs: prefs, } @@ -1513,13 +1481,13 @@ def list_sessions( user_id:, total: nil ) - api_path = '/users/{userId}/sessions' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/sessions' + .gsub('{userId}', user_id) + api_params = { total: total, } @@ -1551,13 +1519,13 @@ def list_sessions( def create_session( user_id: ) - api_path = '/users/{userId}/sessions' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/sessions' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1583,18 +1551,19 @@ def create_session( def delete_sessions( user_id: ) - api_path = '/users/{userId}/sessions' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/sessions' + .gsub('{userId}', user_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1615,23 +1584,24 @@ def delete_session( user_id:, session_id: ) - api_path = '/users/{userId}/sessions/{sessionId}' - .gsub('{userId}', user_id) - .gsub('{sessionId}', session_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/users/{userId}/sessions/{sessionId}' + .gsub('{userId}', user_id) + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1653,10 +1623,7 @@ def update_status( user_id:, status: ) - api_path = '/users/{userId}/status' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1664,6 +1631,9 @@ def update_status( raise Appwrite::Exception.new('Missing required parameter: "status"') end + api_path = '/users/{userId}/status' + .gsub('{userId}', user_id) + api_params = { status: status, } @@ -1695,13 +1665,13 @@ def list_targets( queries: nil, total: nil ) - api_path = '/users/{userId}/targets' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/targets' + .gsub('{userId}', user_id) + api_params = { queries: queries, total: total, @@ -1739,10 +1709,7 @@ def create_target( provider_id: nil, name: nil ) - api_path = '/users/{userId}/targets' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1758,6 +1725,9 @@ def create_target( raise Appwrite::Exception.new('Missing required parameter: "identifier"') end + api_path = '/users/{userId}/targets' + .gsub('{userId}', user_id) + api_params = { targetId: target_id, providerType: provider_type, @@ -1791,18 +1761,18 @@ def get_target( user_id:, target_id: ) - api_path = '/users/{userId}/targets/{targetId}' - .gsub('{userId}', user_id) - .gsub('{targetId}', target_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if target_id.nil? + if target_id.nil? || target_id == '' raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/users/{userId}/targets/{targetId}' + .gsub('{userId}', user_id) + .gsub('{targetId}', target_id) + api_params = {} api_headers = { @@ -1835,18 +1805,18 @@ def update_target( provider_id: nil, name: nil ) - api_path = '/users/{userId}/targets/{targetId}' - .gsub('{userId}', user_id) - .gsub('{targetId}', target_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if target_id.nil? + if target_id.nil? || target_id == '' raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/users/{userId}/targets/{targetId}' + .gsub('{userId}', user_id) + .gsub('{targetId}', target_id) + api_params = { identifier: identifier, providerId: provider_id, @@ -1878,23 +1848,24 @@ def delete_target( user_id:, target_id: ) - api_path = '/users/{userId}/targets/{targetId}' - .gsub('{userId}', user_id) - .gsub('{targetId}', target_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if target_id.nil? + if target_id.nil? || target_id == '' raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/users/{userId}/targets/{targetId}' + .gsub('{userId}', user_id) + .gsub('{targetId}', target_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1921,13 +1892,13 @@ def create_token( length: nil, expire: nil ) - api_path = '/users/{userId}/tokens' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/tokens' + .gsub('{userId}', user_id) + api_params = { length: length, expire: expire, @@ -1958,10 +1929,7 @@ def update_email_verification( user_id:, email_verification: ) - api_path = '/users/{userId}/verification' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1969,6 +1937,9 @@ def update_email_verification( raise Appwrite::Exception.new('Missing required parameter: "emailVerification"') end + api_path = '/users/{userId}/verification' + .gsub('{userId}', user_id) + api_params = { emailVerification: email_verification, } @@ -1998,10 +1969,7 @@ def update_phone_verification( user_id:, phone_verification: ) - api_path = '/users/{userId}/verification/phone' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2009,6 +1977,9 @@ def update_phone_verification( raise Appwrite::Exception.new('Missing required parameter: "phoneVerification"') end + api_path = '/users/{userId}/verification/phone' + .gsub('{userId}', user_id) + api_params = { phoneVerification: phone_verification, } diff --git a/lib/appwrite/services/vectors_db.rb b/lib/appwrite/services/vectors_db.rb index 5d8fe64e..a3440518 100644 --- a/lib/appwrite/services/vectors_db.rb +++ b/lib/appwrite/services/vectors_db.rb @@ -57,8 +57,6 @@ def create( replicas: nil, sync_mode: nil ) - api_path = '/vectorsdb' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -67,6 +65,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/vectorsdb' + api_params = { databaseId: database_id, name: name, @@ -92,8 +92,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -184,13 +184,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/vectorsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/vectorsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -254,18 +254,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/vectorsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -286,13 +287,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/vectorsdb/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -321,13 +322,13 @@ def create_operations( def get( database_id: ) - api_path = '/vectorsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -362,10 +363,7 @@ def update( replicas: nil, sync_mode: nil ) - api_path = '/vectorsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -373,6 +371,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/vectorsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -405,18 +406,19 @@ def update( def delete( database_id: ) - api_path = '/vectorsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -442,13 +444,13 @@ def list_collections( search: nil, total: nil ) - api_path = '/vectorsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -492,10 +494,7 @@ def create_collection( document_security: nil, enabled: nil ) - api_path = '/vectorsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -511,6 +510,9 @@ def create_collection( raise Appwrite::Exception.new('Missing required parameter: "dimension"') end + api_path = '/vectorsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { collectionId: collection_id, name: name, @@ -546,18 +548,18 @@ def get_collection( database_id:, collection_id: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { @@ -594,15 +596,11 @@ def update_collection( document_security: nil, enabled: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -610,6 +608,10 @@ def update_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { name: name, dimension: dimension, @@ -644,23 +646,24 @@ def delete_collection( database_id:, collection_id: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -690,18 +693,18 @@ def list_documents( total: nil, ttl: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -744,15 +747,11 @@ def create_document( permissions: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -764,6 +763,10 @@ def create_document( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documentId: document_id, data: data, @@ -803,15 +806,11 @@ def create_documents( documents:, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -819,6 +818,10 @@ def create_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -857,15 +860,11 @@ def upsert_documents( documents:, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -873,6 +872,10 @@ def upsert_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -911,18 +914,18 @@ def update_documents( queries: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { data: data, queries: queries, @@ -959,18 +962,18 @@ def delete_documents( queries: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1013,18 +1016,18 @@ def create_query( total: nil, ttl: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/query' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/query' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1064,23 +1067,23 @@ def get_document( queries: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1121,23 +1124,23 @@ def upsert_document( permissions: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1178,23 +1181,23 @@ def update_document( permissions: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1230,23 +1233,23 @@ def delete_document( document_id:, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { transactionId: transaction_id, } @@ -1254,6 +1257,7 @@ def delete_document( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1278,18 +1282,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -1331,15 +1335,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1355,6 +1355,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "attributes"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, type: type, @@ -1390,23 +1394,23 @@ def get_index( collection_id:, key: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -1435,28 +1439,29 @@ def delete_index( collection_id:, key: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1485,13 +1490,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/vectorsdb/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1528,13 +1533,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/vectorsdb/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1564,13 +1569,13 @@ def list_operations( def get_replicas( database_id: ) - api_path = '/vectorsdb/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1597,13 +1602,13 @@ def get_replicas( def get_status( database_id: ) - api_path = '/vectorsdb/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/waf.rb b/lib/appwrite/services/waf.rb index 949dd1ee..24a3b0f7 100644 --- a/lib/appwrite/services/waf.rb +++ b/lib/appwrite/services/waf.rb @@ -137,7 +137,7 @@ def update_bypass_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -284,7 +284,7 @@ def update_challenge_rule( difficulty: nil, ttl: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -415,7 +415,7 @@ def update_deny_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -578,7 +578,7 @@ def update_rate_limit_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -728,7 +728,7 @@ def update_redirect_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -771,7 +771,7 @@ def update_redirect_rule( def get_rule( rule_id: ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -833,7 +833,7 @@ def get_rule( def delete_rule( rule_id: ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end diff --git a/lib/appwrite/services/webhooks.rb b/lib/appwrite/services/webhooks.rb index 893cc08e..8f1a17cd 100644 --- a/lib/appwrite/services/webhooks.rb +++ b/lib/appwrite/services/webhooks.rb @@ -47,8 +47,8 @@ def list( # @param [Array] events Events list. Maximum of 100 events are allowed. # @param [] enabled Enable or disable a webhook. # @param [] tls Certificate verification, false for disabled or true for enabled. - # @param [String] auth_username Webhook HTTP user. Max length: 256 chars. - # @param [String] auth_password Webhook HTTP password. Max length: 256 chars. + # @param [String] auth_username Webhook HTTP user. Max length: 255 chars. + # @param [String] auth_password Webhook HTTP password. Max length: 2048 chars. # @param [String] secret Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. # # @return [Webhook] @@ -63,8 +63,6 @@ def create( auth_password: nil, secret: nil ) - api_path = '/webhooks' - if webhook_id.nil? raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end @@ -81,6 +79,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "events"') end + api_path = '/webhooks' + api_params = { webhookId: webhook_id, url: url, @@ -117,13 +117,13 @@ def create( def get( webhook_id: ) - api_path = '/webhooks/{webhookId}' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end + api_path = '/webhooks/{webhookId}' + .gsub('{webhookId}', webhook_id) + api_params = {} api_headers = { @@ -149,8 +149,8 @@ def get( # @param [Array] events Events list. Maximum of 100 events are allowed. # @param [] enabled Enable or disable a webhook. # @param [] tls Certificate verification, false for disabled or true for enabled. - # @param [String] auth_username Webhook HTTP user. Max length: 256 chars. - # @param [String] auth_password Webhook HTTP password. Max length: 256 chars. + # @param [String] auth_username Webhook HTTP user. Max length: 255 chars. + # @param [String] auth_password Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. # # @return [Webhook] def update( @@ -163,10 +163,7 @@ def update( auth_username: nil, auth_password: nil ) - api_path = '/webhooks/{webhookId}' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end @@ -182,6 +179,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "events"') end + api_path = '/webhooks/{webhookId}' + .gsub('{webhookId}', webhook_id) + api_params = { name: name, url: url, @@ -216,18 +216,19 @@ def update( def delete( webhook_id: ) - api_path = '/webhooks/{webhookId}' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end + api_path = '/webhooks/{webhookId}' + .gsub('{webhookId}', webhook_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -250,13 +251,13 @@ def update_secret( webhook_id:, secret: nil ) - api_path = '/webhooks/{webhookId}/secret' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end + api_path = '/webhooks/{webhookId}/secret' + .gsub('{webhookId}', webhook_id) + api_params = { secret: secret, } diff --git a/lib/appwrite/topic.rb b/lib/appwrite/topic.rb new file mode 100644 index 00000000..b9f215bb --- /dev/null +++ b/lib/appwrite/topic.rb @@ -0,0 +1,53 @@ +module Appwrite + # Helper to build MQTT topics for `Push`, level by level. + # + # Topic.path(['user', user_id, 'notification']) # "user/123/notification" + # Topic.path(['org', org_id]).path(['logs']) # "org/42/logs" + class Topic + private_class_method :new + + # Start a topic with the given levels, e.g. `Topic.path(['user', user_id])`. + def self.path(levels) + new([]).path(levels) + end + + def initialize(levels) + @levels = levels.freeze + end + + # Append the given levels. + def path(levels) + self.class.send(:new, @levels + self.class.send(:levels_of, levels)) + end + + def to_s + @levels.join('/') + end + + # Validate the levels passed to `path`: a non-empty array of non-empty strings, none holding + # the level separator `/` or the MQTT wildcards `+` and `#`. + def self.levels_of(levels) + raise ArgumentError, "path() expects an array, e.g. path(['user'])" unless levels.is_a?(Array) + raise ArgumentError, 'path() needs at least one level' if levels.empty? + + levels.each_with_index do |level, index| + unless level.is_a?(String) + type = level.nil? ? 'null' : level.class.name + raise ArgumentError, "level at index #{index} must be a string, got #{type}" + end + raise ArgumentError, "empty level at index #{index}" if level.empty? + + if level.include?('/') + parts = level.split('/', -1).map { |part| "'#{part}'" }.join(', ') + raise ArgumentError, "\"#{level}\" contains \"/\", split it: path([#{parts}])" + end + raise ArgumentError, "\"#{level}\" contains \"+\", not allowed in a topic" if level.include?('+') + raise ArgumentError, "\"#{level}\" contains \"#\", not allowed in a topic" if level.include?('#') + raise ArgumentError, "level at index #{index} contains a NUL character" if level.include?("\0") + end + + levels.dup + end + private_class_method :levels_of + end +end From 42266bc92e2f61cb28edfcaa455099acd7a8613a Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 15 Oct 2026 12:51:51 +0100 Subject: [PATCH 4/4] feat: SDK update for the 2.5.x majors --- CHANGELOG.md | 20 + README.md | 14 +- appwrite.gemspec | 2 +- docs/examples/account/list-logs.md | 17 - docs/examples/account/update-prefs.md | 4 +- docs/examples/avatars/get-screenshot.md | 3 +- docs/examples/databases/create-document.md | 6 +- docs/examples/databases/create-documents.md | 11 +- docs/examples/databases/create-index.md | 2 +- docs/examples/databases/delete-documents.md | 2 +- docs/examples/databases/update-document.md | 6 +- docs/examples/databases/update-documents.md | 6 +- docs/examples/databases/upsert-document.md | 6 +- docs/examples/databases/upsert-documents.md | 11 +- docs/examples/documentsdb/create-document.md | 6 +- docs/examples/documentsdb/create-documents.md | 11 +- docs/examples/documentsdb/create-index.md | 2 +- docs/examples/documentsdb/delete-documents.md | 2 +- docs/examples/documentsdb/upsert-documents.md | 11 +- .../embeddings/create-text-embeddings.md | 2 +- docs/examples/functions/update.md | 3 +- docs/examples/graphql/mutation.md | 4 +- docs/examples/graphql/query.md | 4 +- .../messaging/create-twilio-provider.md | 2 +- docs/examples/mongo/create-restoration.md | 5 +- .../promote-restoration.md} | 9 +- docs/examples/mysql/create-restoration.md | 5 +- .../promote-restoration.md} | 8 +- docs/examples/oauth2/approve.md | 2 +- docs/examples/oauth2/authorize-post.md | 4 +- docs/examples/oauth2/authorize.md | 4 +- .../oauth2/create-device-authorization.md | 4 +- docs/examples/oauth2/create-grant.md | 2 +- docs/examples/oauth2/create-par.md | 4 +- docs/examples/oauth2/create-token.md | 4 +- docs/examples/oauth2/get-grant.md | 2 +- docs/examples/oauth2/list-organizations.md | 2 +- docs/examples/oauth2/list-projects.md | 2 +- docs/examples/oauth2/reject.md | 2 +- docs/examples/oauth2/revoke.md | 2 +- docs/examples/organization/create-key.md | 20 - docs/examples/organization/update-key.md | 20 - .../examples/postgresql/create-restoration.md | 5 +- .../promote-restoration.md} | 7 +- docs/examples/project/create-ephemeral-key.md | 2 +- docs/examples/project/create-smtp-test.md | 2 +- docs/examples/project/update-key.md | 2 +- docs/examples/project/update-labels.md | 2 +- .../examples/project/update-o-auth-2-kakao.md | 4 +- .../get-key.md => proxy/create-smtp-rule.md} | 8 +- docs/examples/storage/get-file-preview.md | 2 +- docs/examples/tablesdb/create-index.md | 2 +- docs/examples/tablesdb/create-row.md | 6 +- docs/examples/tablesdb/create-rows.md | 11 +- docs/examples/tablesdb/delete-rows.md | 2 +- docs/examples/tablesdb/update-row.md | 6 +- docs/examples/tablesdb/update-rows.md | 6 +- docs/examples/tablesdb/upsert-row.md | 6 +- docs/examples/tablesdb/upsert-rows.md | 11 +- docs/examples/teams/create-membership.md | 2 +- docs/examples/teams/update-membership.md | 2 +- docs/examples/users/update-labels.md | 2 +- docs/examples/vectorsdb/create-collection.md | 2 +- docs/examples/vectorsdb/create-document.md | 2 +- docs/examples/vectorsdb/create-documents.md | 15 +- docs/examples/vectorsdb/create-index.md | 2 +- docs/examples/vectorsdb/create-operations.md | 10 +- docs/examples/vectorsdb/delete-documents.md | 2 +- docs/examples/vectorsdb/update-collection.md | 2 +- docs/examples/vectorsdb/upsert-documents.md | 15 +- docs/examples/webhooks/create.md | 2 +- docs/examples/webhooks/update.md | 2 +- lib/appwrite.rb | 15 +- lib/appwrite/client.rb | 34 +- lib/appwrite/enums/billing_plan_group.rb | 1 - lib/appwrite/enums/execution_trigger.rb | 1 + lib/appwrite/enums/organization_key_scopes.rb | 22 - lib/appwrite/enums/proxy_rule_protocol.rb | 8 + lib/appwrite/models/account.rb | 16 +- lib/appwrite/models/activity_event.rb | 1 + lib/appwrite/models/activity_event_list.rb | 1 + lib/appwrite/models/additional_resource.rb | 1 + lib/appwrite/models/algo_argon2.rb | 1 + lib/appwrite/models/algo_bcrypt.rb | 1 + lib/appwrite/models/algo_md5.rb | 1 + lib/appwrite/models/algo_phpass.rb | 1 + lib/appwrite/models/algo_scrypt.rb | 1 + lib/appwrite/models/algo_scrypt_modified.rb | 1 + lib/appwrite/models/algo_sha.rb | 1 + lib/appwrite/models/app.rb | 1 + lib/appwrite/models/app_installation.rb | 3 +- lib/appwrite/models/app_installation_list.rb | 1 + lib/appwrite/models/app_key.rb | 3 +- lib/appwrite/models/app_key_list.rb | 1 + lib/appwrite/models/app_scope.rb | 1 + lib/appwrite/models/app_scope_list.rb | 1 + lib/appwrite/models/app_secret.rb | 3 +- lib/appwrite/models/app_secret_list.rb | 1 + lib/appwrite/models/app_secret_plaintext.rb | 3 +- lib/appwrite/models/apps_list.rb | 1 + lib/appwrite/models/attribute_bigint.rb | 9 +- lib/appwrite/models/attribute_boolean.rb | 5 +- lib/appwrite/models/attribute_datetime.rb | 5 +- lib/appwrite/models/attribute_email.rb | 5 +- lib/appwrite/models/attribute_enum.rb | 5 +- lib/appwrite/models/attribute_float.rb | 9 +- lib/appwrite/models/attribute_integer.rb | 9 +- lib/appwrite/models/attribute_ip.rb | 5 +- lib/appwrite/models/attribute_line.rb | 5 +- lib/appwrite/models/attribute_list.rb | 1 + lib/appwrite/models/attribute_longtext.rb | 7 +- lib/appwrite/models/attribute_mediumtext.rb | 7 +- lib/appwrite/models/attribute_object.rb | 3 +- lib/appwrite/models/attribute_point.rb | 5 +- lib/appwrite/models/attribute_polygon.rb | 5 +- lib/appwrite/models/attribute_relationship.rb | 3 +- lib/appwrite/models/attribute_string.rb | 7 +- lib/appwrite/models/attribute_text.rb | 7 +- lib/appwrite/models/attribute_url.rb | 5 +- lib/appwrite/models/attribute_varchar.rb | 7 +- lib/appwrite/models/attribute_vector.rb | 3 +- lib/appwrite/models/backup_archive.rb | 9 +- lib/appwrite/models/backup_archive_list.rb | 1 + lib/appwrite/models/backup_policy.rb | 5 +- lib/appwrite/models/backup_policy_list.rb | 1 + lib/appwrite/models/backup_restoration.rb | 3 +- .../models/backup_restoration_list.rb | 1 + lib/appwrite/models/billing_limits.rb | 16 +- lib/appwrite/models/billing_plan.rb | 28 +- lib/appwrite/models/billing_plan_addon.rb | 4 +- .../models/billing_plan_addon_details.rb | 3 +- .../billing_plan_dedicated_database_limits.rb | 38 +- lib/appwrite/models/billing_plan_limits.rb | 4 +- .../models/billing_plan_supported_addons.rb | 1 + lib/appwrite/models/block.rb | 37 +- lib/appwrite/models/bucket.rb | 1 + lib/appwrite/models/bucket_list.rb | 1 + lib/appwrite/models/collection.rb | 1 + lib/appwrite/models/collection_list.rb | 1 + lib/appwrite/models/column_bigint.rb | 9 +- lib/appwrite/models/column_boolean.rb | 5 +- lib/appwrite/models/column_datetime.rb | 5 +- lib/appwrite/models/column_email.rb | 5 +- lib/appwrite/models/column_enum.rb | 5 +- lib/appwrite/models/column_float.rb | 9 +- lib/appwrite/models/column_index.rb | 3 +- lib/appwrite/models/column_index_list.rb | 1 + lib/appwrite/models/column_integer.rb | 9 +- lib/appwrite/models/column_ip.rb | 5 +- lib/appwrite/models/column_line.rb | 5 +- lib/appwrite/models/column_list.rb | 1 + lib/appwrite/models/column_longtext.rb | 7 +- lib/appwrite/models/column_mediumtext.rb | 7 +- lib/appwrite/models/column_point.rb | 5 +- lib/appwrite/models/column_polygon.rb | 5 +- lib/appwrite/models/column_relationship.rb | 3 +- lib/appwrite/models/column_string.rb | 7 +- lib/appwrite/models/column_text.rb | 7 +- lib/appwrite/models/column_url.rb | 5 +- lib/appwrite/models/column_varchar.rb | 7 +- lib/appwrite/models/continent.rb | 1 + lib/appwrite/models/continent_list.rb | 1 + lib/appwrite/models/country.rb | 1 + lib/appwrite/models/country_list.rb | 1 + lib/appwrite/models/currency.rb | 1 + lib/appwrite/models/currency_list.rb | 1 + lib/appwrite/models/database.rb | 19 +- lib/appwrite/models/database_list.rb | 1 + lib/appwrite/models/database_migration.rb | 1 + .../models/database_migration_list.rb | 1 + lib/appwrite/models/database_status.rb | 11 +- .../models/database_status_connections.rb | 1 + .../models/database_status_replica.rb | 5 +- lib/appwrite/models/database_status_volume.rb | 1 + lib/appwrite/models/dedicated_database.rb | 15 +- .../models/dedicated_database_backup.rb | 11 +- .../models/dedicated_database_backup_list.rb | 1 + .../dedicated_database_backup_storage.rb | 1 + .../models/dedicated_database_branch.rb | 3 +- .../models/dedicated_database_branch_list.rb | 1 + .../models/dedicated_database_execution.rb | 1 + .../dedicated_database_execution_column.rb | 1 + .../models/dedicated_database_extensions.rb | 1 + .../models/dedicated_database_list.rb | 1 + .../models/dedicated_database_member.rb | 5 +- .../models/dedicated_database_operation.rb | 7 +- .../dedicated_database_operation_list.rb | 1 + .../models/dedicated_database_pitr_windows.rb | 1 + .../models/dedicated_database_pooler.rb | 1 + .../models/dedicated_database_replicas.rb | 5 +- .../models/dedicated_database_restoration.rb | 16 +- .../dedicated_database_restoration_list.rb | 1 + .../dedicated_database_specification.rb | 1 + .../dedicated_database_specification_list.rb | 12 +- ...edicated_database_specification_pricing.rb | 42 - lib/appwrite/models/deployment.rb | 1 + lib/appwrite/models/deployment_list.rb | 1 + lib/appwrite/models/dev_key.rb | 62 - lib/appwrite/models/document.rb | 1 + lib/appwrite/models/document_list.rb | 1 + lib/appwrite/models/domain.rb | 2 +- lib/appwrite/models/domain_price.rb | 4 +- lib/appwrite/models/email_template.rb | 1 + lib/appwrite/models/email_template_list.rb | 1 + lib/appwrite/models/embedding.rb | 1 + lib/appwrite/models/embedding_list.rb | 1 + lib/appwrite/models/ephemeral_key.rb | 1 + lib/appwrite/models/execution.rb | 4 +- lib/appwrite/models/execution_list.rb | 1 + lib/appwrite/models/file.rb | 1 + lib/appwrite/models/file_list.rb | 1 + lib/appwrite/models/framework.rb | 1 + lib/appwrite/models/framework_adapter.rb | 3 +- lib/appwrite/models/framework_list.rb | 1 + lib/appwrite/models/function.rb | 14 +- lib/appwrite/models/function_list.rb | 1 + lib/appwrite/models/headers.rb | 1 + lib/appwrite/models/identity.rb | 1 + lib/appwrite/models/identity_list.rb | 1 + lib/appwrite/models/index.rb | 3 +- lib/appwrite/models/index_list.rb | 1 + lib/appwrite/models/insight.rb | 7 +- lib/appwrite/models/insight_cta.rb | 1 + lib/appwrite/models/insight_list.rb | 1 + lib/appwrite/models/jwt.rb | 1 + lib/appwrite/models/key.rb | 1 + lib/appwrite/models/key_list.rb | 1 + lib/appwrite/models/language.rb | 1 + lib/appwrite/models/language_list.rb | 1 + lib/appwrite/models/locale.rb | 23 +- lib/appwrite/models/locale_code.rb | 1 + lib/appwrite/models/locale_code_list.rb | 1 + lib/appwrite/models/log.rb | 132 -- lib/appwrite/models/log_list.rb | 32 - lib/appwrite/models/membership.rb | 1 + lib/appwrite/models/membership_list.rb | 1 + lib/appwrite/models/message.rb | 7 +- lib/appwrite/models/message_list.rb | 1 + lib/appwrite/models/mfa_challenge.rb | 1 + lib/appwrite/models/mfa_challenge_secret.rb | 1 + lib/appwrite/models/mfa_factors.rb | 1 + lib/appwrite/models/mfa_recovery_codes.rb | 1 + lib/appwrite/models/mfa_type.rb | 1 + lib/appwrite/models/mock_number.rb | 1 + lib/appwrite/models/mock_number_list.rb | 1 + lib/appwrite/models/o_auth2_amazon.rb | 1 + lib/appwrite/models/o_auth2_apple.rb | 1 + lib/appwrite/models/o_auth2_appwrite.rb | 1 + lib/appwrite/models/o_auth2_auth0.rb | 3 +- lib/appwrite/models/o_auth2_authentik.rb | 1 + lib/appwrite/models/o_auth2_autodesk.rb | 1 + lib/appwrite/models/o_auth2_bitbucket.rb | 1 + lib/appwrite/models/o_auth2_bitly.rb | 1 + lib/appwrite/models/o_auth2_box.rb | 1 + lib/appwrite/models/o_auth2_cloudflare.rb | 1 + lib/appwrite/models/o_auth2_dailymotion.rb | 1 + lib/appwrite/models/o_auth2_discord.rb | 3 +- lib/appwrite/models/o_auth2_disqus.rb | 1 + lib/appwrite/models/o_auth2_dropbox.rb | 1 + lib/appwrite/models/o_auth2_etsy.rb | 1 + lib/appwrite/models/o_auth2_facebook.rb | 1 + lib/appwrite/models/o_auth2_figma.rb | 1 + lib/appwrite/models/o_auth2_fusion_auth.rb | 1 + lib/appwrite/models/o_auth2_github.rb | 3 +- lib/appwrite/models/o_auth2_gitlab.rb | 1 + lib/appwrite/models/o_auth2_google.rb | 1 + lib/appwrite/models/o_auth2_hugging_face.rb | 1 + lib/appwrite/models/o_auth2_keycloak.rb | 1 + lib/appwrite/models/o_auth2_kick.rb | 1 + lib/appwrite/models/o_auth2_linkedin.rb | 1 + lib/appwrite/models/o_auth2_microsoft.rb | 3 +- lib/appwrite/models/o_auth2_notion.rb | 1 + lib/appwrite/models/o_auth2_oidc.rb | 13 +- lib/appwrite/models/o_auth2_okta.rb | 3 +- lib/appwrite/models/o_auth2_paypal.rb | 1 + lib/appwrite/models/o_auth2_podio.rb | 1 + lib/appwrite/models/o_auth2_provider_list.rb | 1 + lib/appwrite/models/o_auth2_resend.rb | 1 + lib/appwrite/models/o_auth2_salesforce.rb | 3 +- lib/appwrite/models/o_auth2_slack.rb | 1 + lib/appwrite/models/o_auth2_spotify.rb | 1 + lib/appwrite/models/o_auth2_stripe.rb | 1 + lib/appwrite/models/o_auth2_tradeshift.rb | 1 + lib/appwrite/models/o_auth2_twitch.rb | 1 + lib/appwrite/models/o_auth2_word_press.rb | 1 + lib/appwrite/models/o_auth2_x.rb | 1 + lib/appwrite/models/o_auth2_yahoo.rb | 1 + lib/appwrite/models/o_auth2_yandex.rb | 1 + lib/appwrite/models/o_auth2_zoho.rb | 3 +- lib/appwrite/models/o_auth2_zoom.rb | 1 + lib/appwrite/models/oauth2_approve.rb | 1 + lib/appwrite/models/oauth2_authorize.rb | 1 + lib/appwrite/models/oauth2_consent.rb | 1 + lib/appwrite/models/oauth2_consent_list.rb | 1 + lib/appwrite/models/oauth2_consent_token.rb | 1 + .../models/oauth2_consent_token_list.rb | 1 + .../models/oauth2_device_authorization.rb | 1 + lib/appwrite/models/oauth2_grant.rb | 1 + lib/appwrite/models/oauth2_introspection.rb | 22 +- lib/appwrite/models/oauth2_organization.rb | 1 + .../models/oauth2_organization_list.rb | 1 + lib/appwrite/models/oauth2_par.rb | 1 + lib/appwrite/models/oauth2_project.rb | 1 + lib/appwrite/models/oauth2_project_list.rb | 1 + lib/appwrite/models/oauth2_reject.rb | 1 + lib/appwrite/models/oauth2_token.rb | 5 +- lib/appwrite/models/organization.rb | 41 +- lib/appwrite/models/passkey.rb | 1 + lib/appwrite/models/passkey_challenge.rb | 1 + lib/appwrite/models/passkey_list.rb | 1 + lib/appwrite/models/phone.rb | 1 + lib/appwrite/models/phone_list.rb | 1 + lib/appwrite/models/platform_android.rb | 1 + lib/appwrite/models/platform_apple.rb | 1 + lib/appwrite/models/platform_linux.rb | 1 + lib/appwrite/models/platform_list.rb | 1 + lib/appwrite/models/platform_web.rb | 1 + lib/appwrite/models/platform_windows.rb | 1 + .../models/policy_deny_aliased_email.rb | 1 + .../models/policy_deny_corporate_email.rb | 1 + .../models/policy_deny_disposable_email.rb | 1 + lib/appwrite/models/policy_deny_free_email.rb | 1 + lib/appwrite/models/policy_list.rb | 1 + .../models/policy_membership_privacy.rb | 1 + lib/appwrite/models/policy_mfa_factors.rb | 1 + lib/appwrite/models/policy_passkey.rb | 1 + .../models/policy_password_dictionary.rb | 1 + .../models/policy_password_history.rb | 1 + .../models/policy_password_personal_data.rb | 1 + .../models/policy_password_strength.rb | 1 + lib/appwrite/models/policy_session_alert.rb | 1 + .../models/policy_session_duration.rb | 1 + .../models/policy_session_invalidation.rb | 1 + lib/appwrite/models/policy_session_limit.rb | 1 + lib/appwrite/models/policy_user_limit.rb | 1 + lib/appwrite/models/postgres_extension.rb | 1 + lib/appwrite/models/presence.rb | 7 +- lib/appwrite/models/presence_list.rb | 1 + lib/appwrite/models/program.rb | 1 + lib/appwrite/models/project.rb | 50 +- lib/appwrite/models/project_auth_method.rb | 1 + lib/appwrite/models/project_list.rb | 1 + lib/appwrite/models/project_protocol.rb | 1 + lib/appwrite/models/project_service.rb | 1 + lib/appwrite/models/provider.rb | 3 +- lib/appwrite/models/provider_list.rb | 1 + lib/appwrite/models/proxy_invalidation.rb | 1 + lib/appwrite/models/proxy_rule.rb | 27 +- lib/appwrite/models/proxy_rule_list.rb | 1 + lib/appwrite/models/report.rb | 3 +- lib/appwrite/models/report_list.rb | 1 + lib/appwrite/models/resource_token.rb | 1 + lib/appwrite/models/resource_token_list.rb | 1 + lib/appwrite/models/row.rb | 1 + lib/appwrite/models/row_list.rb | 1 + lib/appwrite/models/runtime.rb | 1 + lib/appwrite/models/runtime_list.rb | 1 + lib/appwrite/models/session.rb | 1 + lib/appwrite/models/session_list.rb | 1 + lib/appwrite/models/site.rb | 1 + lib/appwrite/models/site_list.rb | 1 + lib/appwrite/models/specification.rb | 1 + lib/appwrite/models/specification_list.rb | 1 + lib/appwrite/models/subscriber.rb | 1 + lib/appwrite/models/subscriber_list.rb | 1 + lib/appwrite/models/table.rb | 1 + lib/appwrite/models/table_list.rb | 1 + lib/appwrite/models/target.rb | 3 +- lib/appwrite/models/target_list.rb | 1 + lib/appwrite/models/team.rb | 1 + lib/appwrite/models/team_list.rb | 1 + lib/appwrite/models/token.rb | 1 + lib/appwrite/models/token_secret.rb | 1 + lib/appwrite/models/topic.rb | 5 +- lib/appwrite/models/topic_list.rb | 1 + lib/appwrite/models/transaction.rb | 1 + lib/appwrite/models/transaction_list.rb | 1 + lib/appwrite/models/usage_billing_plan.rb | 54 +- lib/appwrite/models/user.rb | 23 +- lib/appwrite/models/user_list.rb | 1 + lib/appwrite/models/variable.rb | 1 + lib/appwrite/models/variable_list.rb | 1 + lib/appwrite/models/vectorsdb_collection.rb | 1 + .../models/vectorsdb_collection_list.rb | 1 + lib/appwrite/models/webhook.rb | 1 + lib/appwrite/models/webhook_list.rb | 1 + lib/appwrite/query.rb | 190 +++ lib/appwrite/query/builder.rb | 361 +++++ lib/appwrite/services/account.rb | 244 ++-- lib/appwrite/services/activities.rb | 8 +- lib/appwrite/services/advisor.rb | 37 +- lib/appwrite/services/apps.rb | 178 +-- lib/appwrite/services/avatars.rb | 42 +- lib/appwrite/services/backups.rb | 60 +- lib/appwrite/services/databases.rb | 946 ++++++------- lib/appwrite/services/documents_db.rb | 385 +++--- lib/appwrite/services/domains.rb | 110 +- lib/appwrite/services/embeddings.rb | 4 +- lib/appwrite/services/functions.rb | 226 ++-- lib/appwrite/services/graphql.rb | 8 +- lib/appwrite/services/messaging.rb | 308 ++--- lib/appwrite/services/mongo.rb | 324 +++-- lib/appwrite/services/mysql.rb | 356 +++-- lib/appwrite/services/oauth2.rb | 54 +- lib/appwrite/services/organization.rb | 301 +---- lib/appwrite/services/postgresql.rb | 384 +++--- lib/appwrite/services/presences.rb | 33 +- lib/appwrite/services/project.rb | 291 ++-- lib/appwrite/services/proxy.rb | 93 +- lib/appwrite/services/sites.rb | 212 +-- lib/appwrite/services/storage.rb | 121 +- lib/appwrite/services/tables_db.rb | 1170 +++++++++-------- lib/appwrite/services/teams.rb | 164 +-- lib/appwrite/services/tokens.rb | 49 +- lib/appwrite/services/users.rb | 369 +++--- lib/appwrite/services/vectors_db.rb | 357 ++--- lib/appwrite/services/waf.rb | 14 +- lib/appwrite/services/webhooks.rb | 45 +- lib/appwrite/topic.rb | 53 + 419 files changed, 5068 insertions(+), 4247 deletions(-) delete mode 100644 docs/examples/account/list-logs.md rename docs/examples/{users/list-logs.md => mongo/promote-restoration.md} (65%) rename docs/examples/{organization/list-keys.md => mysql/promote-restoration.md} (65%) delete mode 100644 docs/examples/organization/create-key.md delete mode 100644 docs/examples/organization/update-key.md rename docs/examples/{organization/delete-key.md => postgresql/promote-restoration.md} (63%) rename docs/examples/{organization/get-key.md => proxy/create-smtp-rule.md} (62%) delete mode 100644 lib/appwrite/enums/organization_key_scopes.rb create mode 100644 lib/appwrite/enums/proxy_rule_protocol.rb delete mode 100644 lib/appwrite/models/dedicated_database_specification_pricing.rb delete mode 100644 lib/appwrite/models/dev_key.rb delete mode 100644 lib/appwrite/models/log.rb delete mode 100644 lib/appwrite/models/log_list.rb create mode 100644 lib/appwrite/query/builder.rb create mode 100644 lib/appwrite/topic.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index cdc8ff1a..6bc66b03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Change Log +## 29.0.0 + +* Breaking: requests send `X-Appwrite-Response-Format: 2.5.0`; responses follow the 2.5 shapes +* Breaking: removed `account.list_logs`, `users.list_logs` and the `Log`/`LogList` models +* Breaking: removed `organization.create_key`, `get_key`, `list_keys`, `update_key` and `delete_key`, and `OrganizationKeyScopes`; use `organization.list_project_keys`, `get_project_key`, `update_project_key` and `delete_project_key` instead +* Breaking: removed `Client#set_dev_key`, the `DevKey` model and `Project#dev_keys` +* Breaking: removed `BillingPlanGroup::STARTER`; use `BillingPlanGroup::FREE` +* Breaking: `list_specifications` returns each specification's prices and overage rates on the row itself. Removed the list-level `pricing` field and the `DedicatedDatabaseSpecificationPricing` model +* Breaking: removed `Block` fields `reason`, `project_name`, `region`, `organization_name`, `organization_id` and `billing_plan` +* Breaking: OAuth2 `resource:` params now take an array +* Breaking: `BackupRestoration#options` is now a hash +* Breaking: some response fields became optional, such as `BillingPlan#usage` and `DedicatedDatabase#engine` +* Added: `Topic` helper to build MQTT topics for push messages +* Added: `mongo`, `mysql` and `postgresql` `promote_restoration`, `restore_mode:`, `target_name:` and `auto_promote:` on `create_restoration`, and `DedicatedDatabaseRestoration#restore_mode` +* Added: `proxy.create_smtp_rule`, the `ProxyRuleProtocol` enum and `ProxyRule#protocol` +* Added: `email_enabled:` on `functions.update` and `Function`, and `ExecutionTrigger::EMAIL` +* Added: `Query` aggregates (`count`, `count_distinct`, `sum`, `avg`, `min`, `max` and more), `group_by`, `having`, `distinct`, joins, `relationship`, `covers`, `spatial_equals` and `page` +* Added: `Query.builder` to chain queries; `build()` returns the query list +* Updated: missing response fields fall back to their documented defaults in more models + ## 28.4.0 * Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones diff --git a/README.md b/README.md index ebd62348..f37667f0 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite Ruby SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-2.0.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 1.9.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-ruby/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-ruby/releases) when APIs differ. Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Ruby SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -35,7 +35,7 @@ client .set_endpoint(ENV["APPWRITE_ENDPOINT"]) # Your API Endpoint .set_project(ENV["APPWRITE_PROJECT"]) # Your project ID .set_key(ENV["APPWRITE_SECRET"]) # Your secret API key - .setSelfSigned() # Use only on dev mode with a self-signed SSL cert + .set_self_signed # Use only on dev mode with a self-signed SSL cert ; ``` @@ -45,7 +45,7 @@ Once your SDK object is set, create any of the Appwrite service objects and choo ```ruby users = Appwrite::Users.new(client); -user = users.create(userId: Appwrite::ID::unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); +user = users.create(user_id: Appwrite::ID::unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); ``` ### Full Example @@ -58,12 +58,12 @@ client .set_endpoint(ENV["APPWRITE_ENDPOINT"]) # Your API Endpoint .set_project(ENV["APPWRITE_PROJECT"]) # Your project ID .set_key(ENV["APPWRITE_SECRET"]) # Your secret API key - .setSelfSigned() # Use only on dev mode with a self-signed SSL cert + .set_self_signed # Use only on dev mode with a self-signed SSL cert ; users = Appwrite::Users.new(client); -user = users.create(userId: Appwrite::ID::unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); +user = users.create(user_id: Appwrite::ID::unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); ``` ### Error Handling @@ -73,7 +73,7 @@ The Appwrite Ruby SDK raises `Appwrite::Exception` object with `message`, `code` users = Appwrite::Users.new(client); begin - user = users.create(userId: Appwrite::ID::unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); + user = users.create(user_id: Appwrite::ID::unique(), email: "email@example.com", phone: "+123456789", password: "password", name: "Walter O'Brien"); rescue Appwrite::Exception => error puts error.message end diff --git a/appwrite.gemspec b/appwrite.gemspec index 7fe70b3b..4054abff 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '28.4.0' + spec.version = '29.0.0' spec.license = 'BSD-3-Clause' spec.summary = 'Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API' spec.author = 'Appwrite Team' diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md deleted file mode 100644 index 171d4306..00000000 --- a/docs/examples/account/list-logs.md +++ /dev/null @@ -1,17 +0,0 @@ -```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_logs( - queries: [], # optional - total: false # optional -) -``` diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index 847cff42..a4298139 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -12,8 +12,8 @@ account = Account.new(client) result = account.update_prefs( prefs: { - "language" => "en", - "timezone" => "UTC", + "language" => 'en', + "timezone" => 'UTC', "darkTheme" => true } ) diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 742c87fd..83a39ba7 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -14,8 +14,7 @@ avatars = Avatars.new(client) result = avatars.get_screenshot( url: 'https://example.com', headers: { - "Authorization" => "Bearer token123", - "X-Custom-Header" => "value" + "Accept-Language" => 'en-US,en;q=0.9' }, # optional viewport_width: 1920, # optional viewport_height: 1080, # optional diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 6398a210..09283549 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -17,9 +17,9 @@ result = databases.create_document( collection_id: '', document_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 30, "isAdmin" => false }, diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 60acd19f..25b4cbd9 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -13,7 +13,16 @@ databases = Databases.new(client) result = databases.create_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index e3e9238a..924f512f 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -16,7 +16,7 @@ result = databases.create_index( collection_id: '', key: '', type: DatabasesIndexType::KEY, - attributes: [], + attributes: ["username"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index c9309bd9..29ea3583 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -13,7 +13,7 @@ databases = Databases.new(client) result = databases.delete_documents( database_id: '', collection_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 27747e3b..af0d88d9 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -17,9 +17,9 @@ result = databases.update_document( collection_id: '', document_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 33, "isAdmin" => false }, # optional diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index 5ebb951f..e58b6480 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -14,9 +14,9 @@ result = databases.update_documents( database_id: '', collection_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 33, "isAdmin" => false }, # optional diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index d196769e..84b15775 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -17,9 +17,9 @@ result = databases.upsert_document( collection_id: '', document_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 30, "isAdmin" => false }, # optional diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 49432e01..6cf394c5 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -13,7 +13,16 @@ databases = Databases.new(client) result = databases.upsert_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/documentsdb/create-document.md b/docs/examples/documentsdb/create-document.md index 94b68b35..7c78f103 100644 --- a/docs/examples/documentsdb/create-document.md +++ b/docs/examples/documentsdb/create-document.md @@ -17,9 +17,9 @@ result = documents_db.create_document( collection_id: '', document_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 30, "isAdmin" => false }, diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index 1277f4ac..b895f1c5 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -13,7 +13,16 @@ documents_db = DocumentsDB.new(client) result = documents_db.create_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md index d1891f9a..a8c4e35f 100644 --- a/docs/examples/documentsdb/create-index.md +++ b/docs/examples/documentsdb/create-index.md @@ -16,7 +16,7 @@ result = documents_db.create_index( collection_id: '', key: '', type: DocumentsDBIndexType::KEY, - attributes: [], + attributes: ["username"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md index cd628c75..b1ea2032 100644 --- a/docs/examples/documentsdb/delete-documents.md +++ b/docs/examples/documentsdb/delete-documents.md @@ -13,7 +13,7 @@ documents_db = DocumentsDB.new(client) result = documents_db.delete_documents( database_id: '', collection_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md index f7f05970..0876756c 100644 --- a/docs/examples/documentsdb/upsert-documents.md +++ b/docs/examples/documentsdb/upsert-documents.md @@ -13,7 +13,16 @@ documents_db = DocumentsDB.new(client) result = documents_db.upsert_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index facbe573..fecbe281 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -12,7 +12,7 @@ client = Client.new embeddings = Embeddings.new(client) result = embeddings.create_text_embeddings( - texts: [], + texts: ["Appwrite helps developers build applications.", "Find documents with semantic search."], model: EmbeddingModel::NOMIC_EMBED_TEXT # optional ) ``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index ff418bd5..1932fba5 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -34,6 +34,7 @@ result = functions.update( build_specification: 's-1vcpu-512mb', # optional runtime_specification: 's-1vcpu-512mb', # optional deployment_retention: 0, # optional - interval: 0 # optional + interval: 0, # optional + email_enabled: false # optional ) ``` diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index a71a8bd6..79ac983d 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -11,6 +11,8 @@ client = Client.new graphql = Graphql.new(client) result = graphql.mutation( - query: {} + query: { + "query" => 'mutation { accountUpdateName(name: "Walter") { name } }' + } ) ``` diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 49561b15..35046ab9 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -11,6 +11,8 @@ client = Client.new graphql = Graphql.new(client) result = graphql.query( - query: {} + query: { + "query" => 'query { localeGet { ip } }' + } ) ``` diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index fa86a835..a68eec6f 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -13,7 +13,7 @@ messaging = Messaging.new(client) result = messaging.create_twilio_provider( provider_id: '', name: '', - from: '+12065550100', # optional + from: '', # optional account_sid: '', # optional auth_token: '', # optional enabled: false # optional diff --git a/docs/examples/mongo/create-restoration.md b/docs/examples/mongo/create-restoration.md index 43f91beb..90210ea8 100644 --- a/docs/examples/mongo/create-restoration.md +++ b/docs/examples/mongo/create-restoration.md @@ -15,6 +15,9 @@ result = mongo.create_restoration( type: 'backup', # optional backup_id: '', # optional target_database_id: '', # optional - target_time: '2020-10-15T06:38:00.000+00:00' # optional + target_time: '2020-10-15T06:38:00.000+00:00', # optional + restore_mode: 'in_place', # optional + target_name: '', # optional + auto_promote: false # optional ) ``` diff --git a/docs/examples/users/list-logs.md b/docs/examples/mongo/promote-restoration.md similarity index 65% rename from docs/examples/users/list-logs.md rename to docs/examples/mongo/promote-restoration.md index dd9809e3..41bbe464 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/mongo/promote-restoration.md @@ -8,11 +8,10 @@ client = Client.new .set_project('') # Your project ID .set_key('') # Your secret API key -users = Users.new(client) +mongo = Mongo.new(client) -result = users.list_logs( - user_id: '', - queries: [], # optional - total: false # optional +result = mongo.promote_restoration( + database_id: '', + restoration_id: '' ) ``` diff --git a/docs/examples/mysql/create-restoration.md b/docs/examples/mysql/create-restoration.md index ad5aa058..25dc141e 100644 --- a/docs/examples/mysql/create-restoration.md +++ b/docs/examples/mysql/create-restoration.md @@ -15,6 +15,9 @@ result = mysql.create_restoration( type: 'backup', # optional backup_id: '', # optional target_database_id: '', # optional - target_time: '2020-10-15T06:38:00.000+00:00' # optional + target_time: '2020-10-15T06:38:00.000+00:00', # optional + restore_mode: 'in_place', # optional + target_name: '', # optional + auto_promote: false # optional ) ``` diff --git a/docs/examples/organization/list-keys.md b/docs/examples/mysql/promote-restoration.md similarity index 65% rename from docs/examples/organization/list-keys.md rename to docs/examples/mysql/promote-restoration.md index d54a2642..7f499e33 100644 --- a/docs/examples/organization/list-keys.md +++ b/docs/examples/mysql/promote-restoration.md @@ -8,10 +8,10 @@ client = Client.new .set_project('') # Your project ID .set_key('') # Your secret API key -organization = Organization.new(client) +mysql = Mysql.new(client) -result = organization.list_keys( - queries: [], # optional - total: false # optional +result = mysql.promote_restoration( + database_id: '', + restoration_id: '' ) ``` diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md index 6576dbec..99818b87 100644 --- a/docs/examples/oauth2/approve.md +++ b/docs/examples/oauth2/approve.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index 75f092a2..d4f058ce 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -22,7 +22,7 @@ result = oauth2.authorize_post( prompt: '', # optional max_age: 0, # optional authorization_details: '', # optional - resource: '', # optional + resource: [], # optional audience: '', # optional request_uri: '' # optional ) diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index d7d5befc..474e4e96 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -22,7 +22,7 @@ result = oauth2.authorize( prompt: '', # optional max_age: 0, # optional authorization_details: '', # optional - resource: '', # 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 index 102671db..3fde848d 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -14,7 +14,7 @@ result = oauth2.create_device_authorization( client_id: '', # optional scope: '', # optional authorization_details: '', # optional - resource: '', # optional + resource: [], # optional audience: '' # optional ) ``` diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md index 9184cbf7..f4bff9f2 100644 --- a/docs/examples/oauth2/create-grant.md +++ b/docs/examples/oauth2/create-grant.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index 192e5ff1..2ac703ea 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -22,7 +22,7 @@ result = oauth2.create_par( prompt: '', # optional max_age: 0, # optional authorization_details: '', # optional - resource: '', # optional + resource: [], # optional audience: '' # optional ) ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index 6e0cabc1..8b0a9c52 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -19,7 +19,7 @@ result = oauth2.create_token( client_secret: '', # optional code_verifier: '', # optional redirect_uri: 'https://example.com', # optional - resource: '', # optional + resource: [], # optional audience: '' # optional ) ``` diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md index e6b80763..81985286 100644 --- a/docs/examples/oauth2/get-grant.md +++ b/docs/examples/oauth2/get-grant.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md index 28b026e4..2e9ed664 100644 --- a/docs/examples/oauth2/list-organizations.md +++ b/docs/examples/oauth2/list-organizations.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md index 3f8c64f2..f7a69362 100644 --- a/docs/examples/oauth2/list-projects.md +++ b/docs/examples/oauth2/list-projects.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md index bf00d990..e10fd752 100644 --- a/docs/examples/oauth2/reject.md +++ b/docs/examples/oauth2/reject.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md index 6b709451..36c5c145 100644 --- a/docs/examples/oauth2/revoke.md +++ b/docs/examples/oauth2/revoke.md @@ -5,8 +5,8 @@ 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 + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/organization/create-key.md b/docs/examples/organization/create-key.md deleted file mode 100644 index 3d920ccc..00000000 --- a/docs/examples/organization/create-key.md +++ /dev/null @@ -1,20 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite -include Appwrite::Enums - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -organization = Organization.new(client) - -result = organization.create_key( - key_id: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTS_READ], - expire: '2020-10-15T06:38:00.000+00:00' # optional -) -``` diff --git a/docs/examples/organization/update-key.md b/docs/examples/organization/update-key.md deleted file mode 100644 index c7542126..00000000 --- a/docs/examples/organization/update-key.md +++ /dev/null @@ -1,20 +0,0 @@ -```ruby -require 'appwrite' - -include Appwrite -include Appwrite::Enums - -client = Client.new - .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint - .set_project('') # Your project ID - .set_key('') # Your secret API key - -organization = Organization.new(client) - -result = organization.update_key( - key_id: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTS_READ], - expire: '2020-10-15T06:38:00.000+00:00' # optional -) -``` diff --git a/docs/examples/postgresql/create-restoration.md b/docs/examples/postgresql/create-restoration.md index b4a8e988..12cd76c0 100644 --- a/docs/examples/postgresql/create-restoration.md +++ b/docs/examples/postgresql/create-restoration.md @@ -15,6 +15,9 @@ result = postgresql.create_restoration( type: 'backup', # optional backup_id: '', # optional target_database_id: '', # optional - target_time: '2020-10-15T06:38:00.000+00:00' # optional + target_time: '2020-10-15T06:38:00.000+00:00', # optional + restore_mode: 'in_place', # optional + target_name: '', # optional + auto_promote: false # optional ) ``` diff --git a/docs/examples/organization/delete-key.md b/docs/examples/postgresql/promote-restoration.md similarity index 63% rename from docs/examples/organization/delete-key.md rename to docs/examples/postgresql/promote-restoration.md index 0e490c3b..d0aa2bb3 100644 --- a/docs/examples/organization/delete-key.md +++ b/docs/examples/postgresql/promote-restoration.md @@ -8,9 +8,10 @@ client = Client.new .set_project('') # Your project ID .set_key('') # Your secret API key -organization = Organization.new(client) +postgresql = Postgresql.new(client) -result = organization.delete_key( - key_id: '' +result = postgresql.promote_restoration( + database_id: '', + restoration_id: '' ) ``` diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index 6f0d9b66..d7928fa5 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -12,7 +12,7 @@ client = Client.new project = Project.new(client) result = project.create_ephemeral_key( - scopes: [ProjectKeyScopes::PROJECT_READ], + scopes: [ProjectKeyScopes::USERS_READ], duration: 600 ) ``` diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index 1e1d1eae..34853638 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -11,6 +11,6 @@ client = Client.new project = Project.new(client) result = project.create_smtp_test( - emails: [] + emails: ["recipient@example.com"] ) ``` diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index b192315d..992775bb 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -14,7 +14,7 @@ project = Project.new(client) result = project.update_key( key_id: '', name: '', - scopes: [ProjectKeyScopes::PROJECT_READ], + scopes: [ProjectKeyScopes::USERS_READ], expire: '2020-10-15T06:38:00.000+00:00' # optional ) ``` diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index f57cec70..a01667b9 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -11,6 +11,6 @@ client = Client.new project = Project.new(client) result = project.update_labels( - labels: [] + labels: ["production"] ) ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index 035810f7..5acde9f9 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -14,7 +14,7 @@ project = Project.new(client) result = project.update_o_auth2_kakao( client_id: '', # optional client_secret: '', # optional - prompt: [ProjectOAuth2KakaoPrompt::NONE], # optional - enabled: false # optional + enabled: false, # optional + prompt: [ProjectOAuth2KakaoPrompt::NONE] # optional ) ``` diff --git a/docs/examples/organization/get-key.md b/docs/examples/proxy/create-smtp-rule.md similarity index 62% rename from docs/examples/organization/get-key.md rename to docs/examples/proxy/create-smtp-rule.md index 28899bb6..dbbc1c7d 100644 --- a/docs/examples/organization/get-key.md +++ b/docs/examples/proxy/create-smtp-rule.md @@ -8,9 +8,11 @@ client = Client.new .set_project('') # Your project ID .set_key('') # Your secret API key -organization = Organization.new(client) +proxy = Proxy.new(client) -result = organization.get_key( - key_id: '' +result = proxy.create_smtp_rule( + domain: 'example.com', + function_id: '', + branch: '' # optional ) ``` diff --git a/docs/examples/storage/get-file-preview.md b/docs/examples/storage/get-file-preview.md index 3b4ce03d..d40c3a5e 100644 --- a/docs/examples/storage/get-file-preview.md +++ b/docs/examples/storage/get-file-preview.md @@ -16,7 +16,7 @@ result = storage.get_file_preview( file_id: '', width: 0, # optional height: 0, # optional - gravity: ImageGravity::CENTER, # optional + gravity: ImageGravity::AUTO, # optional quality: -1, # optional border_width: 0, # optional border_color: 'FFFFFF', # optional diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index a0453818..d1e2dba7 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -16,7 +16,7 @@ result = tables_db.create_index( table_id: '', key: '', type: TablesDBIndexType::KEY, - columns: [], + columns: ["username"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 60aa4e9d..43a1c537 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -17,9 +17,9 @@ result = tables_db.create_row( table_id: '', row_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 30, "isAdmin" => false }, diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index 2fc8a2b1..9ff8dd78 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -13,7 +13,16 @@ tables_db = TablesDB.new(client) result = tables_db.create_rows( database_id: '', table_id: '', - rows: [], + rows: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 69ab29e8..41d6acdb 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -13,7 +13,7 @@ tables_db = TablesDB.new(client) result = tables_db.delete_rows( database_id: '', table_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index e801cb24..59f396a9 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -17,9 +17,9 @@ result = tables_db.update_row( table_id: '', row_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 33, "isAdmin" => false }, # optional diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 0eb800bd..ebe11daf 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -14,9 +14,9 @@ result = tables_db.update_rows( database_id: '', table_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 33, "isAdmin" => false }, # optional diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 7802e672..fe00e454 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -17,9 +17,9 @@ result = tables_db.upsert_row( table_id: '', row_id: '', data: { - "username" => "walter.obrien", - "email" => "walter.obrien@example.com", - "fullName" => "Walter O'Brien", + "username" => 'walter.obrien', + "email" => 'walter.obrien@example.com', + "fullName" => 'Walter O\'Brien', "age" => 33, "isAdmin" => false }, # optional diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index d450971f..9d5cce80 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -13,7 +13,16 @@ tables_db = TablesDB.new(client) result = tables_db.upsert_rows( database_id: '', table_id: '', - rows: [], + rows: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index c90a80d6..9016bb71 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -12,7 +12,7 @@ teams = Teams.new(client) result = teams.create_membership( team_id: '', - roles: [], + roles: ["editor"], email: 'email@example.com', # optional user_id: '', # optional phone: '+12065550100', # optional diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index f94e3879..898f7eae 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -13,6 +13,6 @@ teams = Teams.new(client) result = teams.update_membership( team_id: '', membership_id: '', - roles: [] + roles: ["editor"] ) ``` diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 0110cb9e..bdad6d04 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -12,6 +12,6 @@ users = Users.new(client) result = users.update_labels( user_id: '', - labels: [] + labels: ["subscriber"] ) ``` diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md index b449f541..4b16940b 100644 --- a/docs/examples/vectorsdb/create-collection.md +++ b/docs/examples/vectorsdb/create-collection.md @@ -16,7 +16,7 @@ result = vectors_db.create_collection( database_id: '', collection_id: '', name: '', - dimension: 1, + dimension: 4, permissions: [Permission.read(Role.any())], # optional document_security: false, # optional enabled: false # optional diff --git a/docs/examples/vectorsdb/create-document.md b/docs/examples/vectorsdb/create-document.md index 648d9b2c..a83f352c 100644 --- a/docs/examples/vectorsdb/create-document.md +++ b/docs/examples/vectorsdb/create-document.md @@ -24,7 +24,7 @@ result = vectors_db.create_document( "3" => 1.02 }, "metadata" => { - "key" => "value" + "key" => 'value' } }, permissions: [Permission.read(Role.any())], # optional diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index 9f3a4d4d..3a89c1ee 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -13,7 +13,20 @@ vectors_db = VectorsDB.new(client) result = vectors_db.create_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md index d7880ab2..60d2624a 100644 --- a/docs/examples/vectorsdb/create-index.md +++ b/docs/examples/vectorsdb/create-index.md @@ -16,7 +16,7 @@ result = vectors_db.create_index( collection_id: '', key: '', type: VectorsDBIndexType::HNSW_EUCLIDEAN, - attributes: [], + attributes: ["embeddings"], orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md index 6817930b..23e14d1c 100644 --- a/docs/examples/vectorsdb/create-operations.md +++ b/docs/examples/vectorsdb/create-operations.md @@ -19,7 +19,15 @@ result = vectors_db.create_operations( "collectionId": "", "documentId": "", "data": { - "name": "Walter O'Brien" + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } } } ] # optional diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md index bb1173a3..a050c8c3 100644 --- a/docs/examples/vectorsdb/delete-documents.md +++ b/docs/examples/vectorsdb/delete-documents.md @@ -13,7 +13,7 @@ vectors_db = VectorsDB.new(client) result = vectors_db.delete_documents( database_id: '', collection_id: '', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], # optional transaction_id: '' # optional ) ``` diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md index 0dfdac13..eee8c975 100644 --- a/docs/examples/vectorsdb/update-collection.md +++ b/docs/examples/vectorsdb/update-collection.md @@ -16,7 +16,7 @@ result = vectors_db.update_collection( database_id: '', collection_id: '', name: '', - dimension: 1, # optional + dimension: 4, # optional permissions: [Permission.read(Role.any())], # optional document_security: false, # optional enabled: false # optional diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md index d737f107..e1fea6cc 100644 --- a/docs/examples/vectorsdb/upsert-documents.md +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -13,7 +13,20 @@ vectors_db = VectorsDB.new(client) result = vectors_db.upsert_documents( database_id: '', collection_id: '', - documents: [], + documents: [ + { + "$id": "example1", + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } + } + ], transaction_id: '' # optional ) ``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index 9f231f7b..6d754424 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -14,7 +14,7 @@ result = webhooks.create( webhook_id: '', url: 'https://example.com/webhook', name: '', - events: [], + events: ["users.*.create"], enabled: false, # optional tls: false, # optional auth_username: '', # optional diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index ad3fa894..859d15f2 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -14,7 +14,7 @@ result = webhooks.update( webhook_id: '', name: '', url: 'https://example.com/webhook', - events: [], + events: ["users.*.create"], enabled: false, # optional tls: false, # optional auth_username: '', # optional diff --git a/lib/appwrite.rb b/lib/appwrite.rb index 7cf6053d..fbd8c530 100644 --- a/lib/appwrite.rb +++ b/lib/appwrite.rb @@ -11,6 +11,7 @@ require_relative 'appwrite/permission' require_relative 'appwrite/role' require_relative 'appwrite/id' +require_relative 'appwrite/topic' require_relative 'appwrite/operator' require_relative 'appwrite/models/row_list' @@ -24,7 +25,6 @@ require_relative 'appwrite/models/user_list' require_relative 'appwrite/models/session_list' require_relative 'appwrite/models/identity_list' -require_relative 'appwrite/models/log_list' require_relative 'appwrite/models/file_list' require_relative 'appwrite/models/bucket_list' require_relative 'appwrite/models/resource_token_list' @@ -111,7 +111,6 @@ require_relative 'appwrite/models/row' require_relative 'appwrite/models/document' require_relative 'appwrite/models/presence' -require_relative 'appwrite/models/log' require_relative 'appwrite/models/user' require_relative 'appwrite/models/algo_md5' require_relative 'appwrite/models/algo_sha' @@ -147,7 +146,6 @@ require_relative 'appwrite/models/webhook' require_relative 'appwrite/models/key' require_relative 'appwrite/models/ephemeral_key' -require_relative 'appwrite/models/dev_key' require_relative 'appwrite/models/mock_number' require_relative 'appwrite/models/o_auth2_github' require_relative 'appwrite/models/o_auth2_discord' @@ -211,6 +209,10 @@ require_relative 'appwrite/models/policy_membership_privacy' require_relative 'appwrite/models/policy_mfa_factors' require_relative 'appwrite/models/policy_passkey' +require_relative 'appwrite/models/policy_deny_aliased_email' +require_relative 'appwrite/models/policy_deny_disposable_email' +require_relative 'appwrite/models/policy_deny_free_email' +require_relative 'appwrite/models/policy_deny_corporate_email' require_relative 'appwrite/models/platform_web' require_relative 'appwrite/models/platform_apple' require_relative 'appwrite/models/platform_android' @@ -280,10 +282,6 @@ require_relative 'appwrite/models/organization' require_relative 'appwrite/models/dedicated_database_pitr_windows' require_relative 'appwrite/models/backup_policy' -require_relative 'appwrite/models/policy_deny_aliased_email' -require_relative 'appwrite/models/policy_deny_disposable_email' -require_relative 'appwrite/models/policy_deny_free_email' -require_relative 'appwrite/models/policy_deny_corporate_email' require_relative 'appwrite/models/dedicated_database_pooler' require_relative 'appwrite/models/postgres_extension' require_relative 'appwrite/models/program' @@ -291,7 +289,6 @@ require_relative 'appwrite/models/dedicated_database_restoration_list' 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' @@ -366,7 +363,6 @@ require_relative 'appwrite/enums/execution_method' require_relative 'appwrite/enums/message_priority' require_relative 'appwrite/enums/smtp_encryption' -require_relative 'appwrite/enums/organization_key_scopes' require_relative 'appwrite/enums/region' require_relative 'appwrite/enums/project_auth_method_id' require_relative 'appwrite/enums/project_o_auth2_auth0_prompt' @@ -420,6 +416,7 @@ require_relative 'appwrite/enums/platform_type' require_relative 'appwrite/enums/proxy_rule_deployment_resource_type' require_relative 'appwrite/enums/proxy_rule_status' +require_relative 'appwrite/enums/proxy_rule_protocol' require_relative 'appwrite/enums/message_status' require_relative 'appwrite/enums/billing_plan_group' require_relative 'appwrite/enums/domain_transfer_status_enum' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index 99f8f563..dab212e9 100644 --- a/lib/appwrite/client.rb +++ b/lib/appwrite/client.rb @@ -14,8 +14,8 @@ def initialize 'x-sdk-name' => 'Ruby', 'x-sdk-platform' => 'server', 'x-sdk-language' => 'ruby', - 'x-sdk-version' => '28.4.0', - 'X-Appwrite-Response-Format' => '2.0.0' + 'x-sdk-version' => '29.0.0', + 'X-Appwrite-Response-Format' => '2.5.0' } @endpoint = 'https://cloud.appwrite.io/v1' @config = {} @@ -130,20 +130,6 @@ def set_forwarded_user_agent(value) self end - # Set DevKey - # - # Your secret dev API key - # - # @param [String] value The value to set for the DevKey header - # - # @return [self] - def set_dev_key(value) - add_header('x-appwrite-dev-key', value) - @config['devkey'] = value - - self - end - # Set Cookie # # The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. @@ -265,6 +251,8 @@ def call( params: {}, response_type: nil ) + params = params.transform_values { |value| Query._flatten(value) } + separator = path.include?('?') ? '&' : '?' uri = URI.parse(@endpoint + path + ((method == "GET" && params.length) ? separator + encode(params) : '')) @@ -283,6 +271,16 @@ def chunked_upload( ) input_file = params[param_name.to_sym] + if input_file.nil? + return call( + method: method, + path: path, + headers: headers, + params: params, + response_type: response_type, + ) + end + case input_file.source_type when 'path' size = ::File.size(input_file.path) @@ -290,7 +288,7 @@ def chunked_upload( size = input_file.data.bytesize end - if size < @chunk_size + if size <= @chunk_size || response_type == "text" if input_file.source_type == 'path' input_file.data = IO.read(input_file.path) end @@ -546,6 +544,8 @@ def decode_text(response) def encode_form_data(value, key = nil) case value when Hash + return encode_form_data(value.to_json, key) unless key.nil? + value.map { |k, v| encode_form_data(v, k) }.join when Array value.map { |v| encode_form_data(v, "#{key}[]") }.join diff --git a/lib/appwrite/enums/billing_plan_group.rb b/lib/appwrite/enums/billing_plan_group.rb index 1f3ca3cf..59fde6e6 100644 --- a/lib/appwrite/enums/billing_plan_group.rb +++ b/lib/appwrite/enums/billing_plan_group.rb @@ -1,7 +1,6 @@ module Appwrite module Enums module BillingPlanGroup - STARTER = 'starter' FREE = 'free' START = 'start' PRO = 'pro' diff --git a/lib/appwrite/enums/execution_trigger.rb b/lib/appwrite/enums/execution_trigger.rb index 59428c6d..f5d58520 100644 --- a/lib/appwrite/enums/execution_trigger.rb +++ b/lib/appwrite/enums/execution_trigger.rb @@ -4,6 +4,7 @@ module ExecutionTrigger HTTP = 'http' SCHEDULE = 'schedule' EVENT = 'event' + EMAIL = 'email' end end end diff --git a/lib/appwrite/enums/organization_key_scopes.rb b/lib/appwrite/enums/organization_key_scopes.rb deleted file mode 100644 index 9a8c7aa3..00000000 --- a/lib/appwrite/enums/organization_key_scopes.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Appwrite - module Enums - module OrganizationKeyScopes - PROJECTS_READ = 'projects.read' - PROJECTS_WRITE = 'projects.write' - DEVKEYS_READ = 'devKeys.read' - 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' - ORGANIZATION_WRITE = 'organization.write' - DOMAINS_READ = 'domains.read' - DOMAINS_WRITE = 'domains.write' - KEYS_READ = 'keys.read' - KEYS_WRITE = 'keys.write' - end - end -end diff --git a/lib/appwrite/enums/proxy_rule_protocol.rb b/lib/appwrite/enums/proxy_rule_protocol.rb new file mode 100644 index 00000000..4c1fd4a1 --- /dev/null +++ b/lib/appwrite/enums/proxy_rule_protocol.rb @@ -0,0 +1,8 @@ +module Appwrite + module Enums + module ProxyRuleProtocol + HTTP = 'http' + SMTP = 'smtp' + end + end +end diff --git a/lib/appwrite/models/account.rb b/lib/appwrite/models/account.rb index 64bcf5f5..bee6f19c 100644 --- a/lib/appwrite/models/account.rb +++ b/lib/appwrite/models/account.rb @@ -40,19 +40,19 @@ def initialize( email:, phone:, email_verification:, - email_canonical:, - email_is_free:, - email_is_disposable:, - email_is_corporate:, - email_is_canonical:, - password_pwned:, + email_canonical: nil, + email_is_free: nil, + email_is_disposable: nil, + email_is_corporate: nil, + email_is_canonical: nil, + password_pwned: nil, phone_verification:, mfa:, prefs:, targets:, accessed_at:, - impersonator:, - impersonator_user_id: + impersonator: false, + impersonator_user_id: nil ) @id = id @created_at = created_at diff --git a/lib/appwrite/models/activity_event.rb b/lib/appwrite/models/activity_event.rb index 34699a2b..ed92c606 100644 --- a/lib/appwrite/models/activity_event.rb +++ b/lib/appwrite/models/activity_event.rb @@ -96,6 +96,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "actorType" => "", "actorId" => "", "actorEmail" => "", "actorName" => "", "resourceParent" => "", "resourceType" => "", "resourceId" => "", "resource" => "", "event" => "", "userAgent" => "", "ip" => "", "mode" => "", "country" => "", "continentCode" => "", "city" => "", "subdivisions" => "", "isp" => "", "autonomousSystemNumber" => "", "autonomousSystemOrganization" => "", "connectionType" => "", "connectionUsageType" => "", "connectionOrganization" => "", "time" => "", "projectId" => "", "teamId" => "", "hostname" => "", "sdk" => "", "sdkVersion" => "" }.merge(map) ActivityEvent.new( id: map["$id"], actor_type: map["actorType"], diff --git a/lib/appwrite/models/activity_event_list.rb b/lib/appwrite/models/activity_event_list.rb index 6c8ebfe3..214f21cd 100644 --- a/lib/appwrite/models/activity_event_list.rb +++ b/lib/appwrite/models/activity_event_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "events" => [] }.merge(map) ActivityEventList.new( total: map["total"], events: map["events"].map { |it| ActivityEvent.from(map: it) } diff --git a/lib/appwrite/models/additional_resource.rb b/lib/appwrite/models/additional_resource.rb index 54d3ad41..fea38e38 100644 --- a/lib/appwrite/models/additional_resource.rb +++ b/lib/appwrite/models/additional_resource.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "unit" => "", "currency" => "", "price" => 0, "value" => 0, "invoiceDesc" => "" }.merge(map) AdditionalResource.new( name: map["name"], unit: map["unit"], diff --git a/lib/appwrite/models/algo_argon2.rb b/lib/appwrite/models/algo_argon2.rb index d2413e72..213dc487 100644 --- a/lib/appwrite/models/algo_argon2.rb +++ b/lib/appwrite/models/algo_argon2.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "type" => "argon2", "memoryCost" => 0, "timeCost" => 0, "threads" => 0 }.merge(map) AlgoArgon2.new( type: map["type"], memory_cost: map["memoryCost"], diff --git a/lib/appwrite/models/algo_bcrypt.rb b/lib/appwrite/models/algo_bcrypt.rb index 0407c819..13c7758c 100644 --- a/lib/appwrite/models/algo_bcrypt.rb +++ b/lib/appwrite/models/algo_bcrypt.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "bcrypt" }.merge(map) AlgoBcrypt.new( type: map["type"] ) diff --git a/lib/appwrite/models/algo_md5.rb b/lib/appwrite/models/algo_md5.rb index d7f315c9..0a79ce23 100644 --- a/lib/appwrite/models/algo_md5.rb +++ b/lib/appwrite/models/algo_md5.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "md5" }.merge(map) AlgoMd5.new( type: map["type"] ) diff --git a/lib/appwrite/models/algo_phpass.rb b/lib/appwrite/models/algo_phpass.rb index 496d2065..2a44c3b6 100644 --- a/lib/appwrite/models/algo_phpass.rb +++ b/lib/appwrite/models/algo_phpass.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "phpass" }.merge(map) AlgoPhpass.new( type: map["type"] ) diff --git a/lib/appwrite/models/algo_scrypt.rb b/lib/appwrite/models/algo_scrypt.rb index 7128bb2f..8cf555c8 100644 --- a/lib/appwrite/models/algo_scrypt.rb +++ b/lib/appwrite/models/algo_scrypt.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "type" => "scrypt", "costCpu" => 8, "costMemory" => 14, "costParallel" => 1, "length" => 64 }.merge(map) AlgoScrypt.new( type: map["type"], cost_cpu: map["costCpu"], diff --git a/lib/appwrite/models/algo_scrypt_modified.rb b/lib/appwrite/models/algo_scrypt_modified.rb index 8862154c..3a27d34d 100644 --- a/lib/appwrite/models/algo_scrypt_modified.rb +++ b/lib/appwrite/models/algo_scrypt_modified.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "type" => "scryptMod", "salt" => "", "saltSeparator" => "", "signerKey" => "" }.merge(map) AlgoScryptModified.new( type: map["type"], salt: map["salt"], diff --git a/lib/appwrite/models/algo_sha.rb b/lib/appwrite/models/algo_sha.rb index bd227d57..16dc3be8 100644 --- a/lib/appwrite/models/algo_sha.rb +++ b/lib/appwrite/models/algo_sha.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "type" => "sha" }.merge(map) AlgoSha.new( type: map["type"] ) diff --git a/lib/appwrite/models/app.rb b/lib/appwrite/models/app.rb index 5123fbd9..13af49c0 100644 --- a/lib/appwrite/models/app.rb +++ b/lib/appwrite/models/app.rb @@ -87,6 +87,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "description" => "", "clientUri" => "", "logoUri" => "", "privacyPolicyUrl" => "", "termsUrl" => "", "contacts" => [], "tagline" => "", "tags" => [], "labels" => [], "images" => [], "supportUrl" => "", "dataDeletionUrl" => "", "redirectUris" => [], "postLogoutRedirectUris" => [], "enabled" => true, "type" => "confidential", "deviceFlow" => false, "teamId" => "", "userId" => "", "installationScopes" => [], "installationRedirectUrl" => "", "secrets" => [] }.merge(map) App.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_installation.rb b/lib/appwrite/models/app_installation.rb index 32a12a3e..ba1009dd 100644 --- a/lib/appwrite/models/app_installation.rb +++ b/lib/appwrite/models/app_installation.rb @@ -24,7 +24,7 @@ def initialize( authorization_details:, created_by_id:, created_by_name:, - last_accessed_at: + last_accessed_at: nil ) @id = id @created_at = created_at @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "teamId" => "", "scopes" => [], "authorizationDetails" => [], "createdById" => "", "createdByName" => "" }.merge(map) AppInstallation.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_installation_list.rb b/lib/appwrite/models/app_installation_list.rb index d59981cc..0efb5504 100644 --- a/lib/appwrite/models/app_installation_list.rb +++ b/lib/appwrite/models/app_installation_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "installations" => [] }.merge(map) AppInstallationList.new( total: map["total"], installations: map["installations"].map { |it| AppInstallation.from(map: it) } diff --git a/lib/appwrite/models/app_key.rb b/lib/appwrite/models/app_key.rb index f1a457f8..86863691 100644 --- a/lib/appwrite/models/app_key.rb +++ b/lib/appwrite/models/app_key.rb @@ -22,7 +22,7 @@ def initialize( hint:, created_by_id:, created_by_name:, - last_accessed_at: + last_accessed_at: nil ) @id = id @created_at = created_at @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "secret" => "", "hint" => "", "createdById" => "", "createdByName" => "" }.merge(map) AppKey.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_key_list.rb b/lib/appwrite/models/app_key_list.rb index 3ec9ecd7..7d2af88f 100644 --- a/lib/appwrite/models/app_key_list.rb +++ b/lib/appwrite/models/app_key_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "keys" => [] }.merge(map) AppKeyList.new( total: map["total"], keys: map["keys"].map { |it| AppKey.from(map: it) } diff --git a/lib/appwrite/models/app_scope.rb b/lib/appwrite/models/app_scope.rb index c12c0ccc..bd068e37 100644 --- a/lib/appwrite/models/app_scope.rb +++ b/lib/appwrite/models/app_scope.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "value" => "", "description" => "", "type" => "", "category" => "", "deprecated" => false }.merge(map) AppScope.new( value: map["value"], description: map["description"], diff --git a/lib/appwrite/models/app_scope_list.rb b/lib/appwrite/models/app_scope_list.rb index 8a7b772b..82426a7c 100644 --- a/lib/appwrite/models/app_scope_list.rb +++ b/lib/appwrite/models/app_scope_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "scopes" => [] }.merge(map) AppScopeList.new( total: map["total"], scopes: map["scopes"].map { |it| AppScope.from(map: it) } diff --git a/lib/appwrite/models/app_secret.rb b/lib/appwrite/models/app_secret.rb index 4170d66c..3b9b9644 100644 --- a/lib/appwrite/models/app_secret.rb +++ b/lib/appwrite/models/app_secret.rb @@ -22,7 +22,7 @@ def initialize( hint:, created_by_id:, created_by_name:, - last_accessed_at: + last_accessed_at: nil ) @id = id @created_at = created_at @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "secret" => "", "hint" => "", "createdById" => "", "createdByName" => "" }.merge(map) AppSecret.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/app_secret_list.rb b/lib/appwrite/models/app_secret_list.rb index d4da1d58..0f1b1a5b 100644 --- a/lib/appwrite/models/app_secret_list.rb +++ b/lib/appwrite/models/app_secret_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "secrets" => [] }.merge(map) AppSecretList.new( total: map["total"], secrets: map["secrets"].map { |it| AppSecret.from(map: it) } diff --git a/lib/appwrite/models/app_secret_plaintext.rb b/lib/appwrite/models/app_secret_plaintext.rb index d36c260a..f4d92779 100644 --- a/lib/appwrite/models/app_secret_plaintext.rb +++ b/lib/appwrite/models/app_secret_plaintext.rb @@ -22,7 +22,7 @@ def initialize( hint:, created_by_id:, created_by_name:, - last_accessed_at: + last_accessed_at: nil ) @id = id @created_at = created_at @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "secret" => "", "hint" => "", "createdById" => "", "createdByName" => "" }.merge(map) AppSecretPlaintext.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/apps_list.rb b/lib/appwrite/models/apps_list.rb index 354957bc..cff5c27a 100644 --- a/lib/appwrite/models/apps_list.rb +++ b/lib/appwrite/models/apps_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "apps" => [] }.merge(map) AppsList.new( total: map["total"], apps: map["apps"].map { |it| App.from(map: it) } diff --git a/lib/appwrite/models/attribute_bigint.rb b/lib/appwrite/models/attribute_bigint.rb index b2286d7a..d53b6eec 100644 --- a/lib/appwrite/models/attribute_bigint.rb +++ b/lib/appwrite/models/attribute_bigint.rb @@ -21,12 +21,12 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - min:, - max:, - default: + min: nil, + max: nil, + default: nil ) @key = key @type = type @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeBigint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_boolean.rb b/lib/appwrite/models/attribute_boolean.rb index 145da450..0ce271d9 100644 --- a/lib/appwrite/models/attribute_boolean.rb +++ b/lib/appwrite/models/attribute_boolean.rb @@ -19,10 +19,10 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - default: + default: nil ) @key = key @type = type @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeBoolean.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_datetime.rb b/lib/appwrite/models/attribute_datetime.rb index 2cd2387e..b47d44cb 100644 --- a/lib/appwrite/models/attribute_datetime.rb +++ b/lib/appwrite/models/attribute_datetime.rb @@ -20,11 +20,11 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, format:, - default: + default: nil ) @key = key @type = type @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeDatetime.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_email.rb b/lib/appwrite/models/attribute_email.rb index d3dc9589..4812c7d4 100644 --- a/lib/appwrite/models/attribute_email.rb +++ b/lib/appwrite/models/attribute_email.rb @@ -20,11 +20,11 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, format:, - default: + default: nil ) @key = key @type = type @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "email" }.merge(map) AttributeEmail.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_enum.rb b/lib/appwrite/models/attribute_enum.rb index 758db16d..56dcf140 100644 --- a/lib/appwrite/models/attribute_enum.rb +++ b/lib/appwrite/models/attribute_enum.rb @@ -21,12 +21,12 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, elements:, format:, - default: + default: nil ) @key = key @type = type @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "elements" => [], "format" => "enum" }.merge(map) AttributeEnum.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_float.rb b/lib/appwrite/models/attribute_float.rb index fd4c2581..2ca764fa 100644 --- a/lib/appwrite/models/attribute_float.rb +++ b/lib/appwrite/models/attribute_float.rb @@ -21,12 +21,12 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - min:, - max:, - default: + min: nil, + max: nil, + default: nil ) @key = key @type = type @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeFloat.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_integer.rb b/lib/appwrite/models/attribute_integer.rb index 0707b347..b3e70729 100644 --- a/lib/appwrite/models/attribute_integer.rb +++ b/lib/appwrite/models/attribute_integer.rb @@ -21,12 +21,12 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - min:, - max:, - default: + min: nil, + max: nil, + default: nil ) @key = key @type = type @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeInteger.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_ip.rb b/lib/appwrite/models/attribute_ip.rb index 4ac5e3b2..dd8e68f3 100644 --- a/lib/appwrite/models/attribute_ip.rb +++ b/lib/appwrite/models/attribute_ip.rb @@ -20,11 +20,11 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, format:, - default: + default: nil ) @key = key @type = type @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "ip" }.merge(map) AttributeIp.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_line.rb b/lib/appwrite/models/attribute_line.rb index 23cda309..db2bca0d 100644 --- a/lib/appwrite/models/attribute_line.rb +++ b/lib/appwrite/models/attribute_line.rb @@ -19,10 +19,10 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - default: + default: nil ) @key = key @type = type @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeLine.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_list.rb b/lib/appwrite/models/attribute_list.rb index 4aafafbc..dad98609 100644 --- a/lib/appwrite/models/attribute_list.rb +++ b/lib/appwrite/models/attribute_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "attributes" => [] }.merge(map) AttributeList.new( total: map["total"], attributes: map["attributes"] diff --git a/lib/appwrite/models/attribute_longtext.rb b/lib/appwrite/models/attribute_longtext.rb index 55922b0a..e09091b5 100644 --- a/lib/appwrite/models/attribute_longtext.rb +++ b/lib/appwrite/models/attribute_longtext.rb @@ -20,11 +20,11 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - default:, - encrypt: + default: nil, + encrypt: false ) @key = key @type = type @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeLongtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_mediumtext.rb b/lib/appwrite/models/attribute_mediumtext.rb index 0dea9331..a897a45d 100644 --- a/lib/appwrite/models/attribute_mediumtext.rb +++ b/lib/appwrite/models/attribute_mediumtext.rb @@ -20,11 +20,11 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - default:, - encrypt: + default: nil, + encrypt: false ) @key = key @type = type @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeMediumtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_object.rb b/lib/appwrite/models/attribute_object.rb index ab85153d..d8b55a3f 100644 --- a/lib/appwrite/models/attribute_object.rb +++ b/lib/appwrite/models/attribute_object.rb @@ -18,7 +18,7 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at: ) @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeObject.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_point.rb b/lib/appwrite/models/attribute_point.rb index b236cb17..514985ee 100644 --- a/lib/appwrite/models/attribute_point.rb +++ b/lib/appwrite/models/attribute_point.rb @@ -19,10 +19,10 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - default: + default: nil ) @key = key @type = type @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributePoint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_polygon.rb b/lib/appwrite/models/attribute_polygon.rb index 44ce447a..371d0bb9 100644 --- a/lib/appwrite/models/attribute_polygon.rb +++ b/lib/appwrite/models/attribute_polygon.rb @@ -19,10 +19,10 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - default: + default: nil ) @key = key @type = type @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributePolygon.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_relationship.rb b/lib/appwrite/models/attribute_relationship.rb index 9b8da81c..4e04e69e 100644 --- a/lib/appwrite/models/attribute_relationship.rb +++ b/lib/appwrite/models/attribute_relationship.rb @@ -24,7 +24,7 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, related_collection:, @@ -51,6 +51,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "relationType" => "", "twoWay" => false, "twoWayKey" => "", "onDelete" => "restrict", "side" => "" }.merge(map) AttributeRelationship.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_string.rb b/lib/appwrite/models/attribute_string.rb index e5e27203..8953404a 100644 --- a/lib/appwrite/models/attribute_string.rb +++ b/lib/appwrite/models/attribute_string.rb @@ -21,12 +21,12 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, size:, - default:, - encrypt: + default: nil, + encrypt: false ) @key = key @type = type @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) AttributeString.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_text.rb b/lib/appwrite/models/attribute_text.rb index 3997ad15..537060ee 100644 --- a/lib/appwrite/models/attribute_text.rb +++ b/lib/appwrite/models/attribute_text.rb @@ -20,11 +20,11 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - default:, - encrypt: + default: nil, + encrypt: false ) @key = key @type = type @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) AttributeText.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_url.rb b/lib/appwrite/models/attribute_url.rb index 2353dc79..45ffd31e 100644 --- a/lib/appwrite/models/attribute_url.rb +++ b/lib/appwrite/models/attribute_url.rb @@ -20,11 +20,11 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, format:, - default: + default: nil ) @key = key @type = type @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "url" }.merge(map) AttributeUrl.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_varchar.rb b/lib/appwrite/models/attribute_varchar.rb index 3720b0e0..9313bfd2 100644 --- a/lib/appwrite/models/attribute_varchar.rb +++ b/lib/appwrite/models/attribute_varchar.rb @@ -21,12 +21,12 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, size:, - default:, - encrypt: + default: nil, + encrypt: false ) @key = key @type = type @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) AttributeVarchar.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/attribute_vector.rb b/lib/appwrite/models/attribute_vector.rb index 3954eefd..3bf92614 100644 --- a/lib/appwrite/models/attribute_vector.rb +++ b/lib/appwrite/models/attribute_vector.rb @@ -19,7 +19,7 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, size: @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) AttributeVector.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/backup_archive.rb b/lib/appwrite/models/backup_archive.rb index 71ea159d..f9f7312e 100644 --- a/lib/appwrite/models/backup_archive.rb +++ b/lib/appwrite/models/backup_archive.rb @@ -21,14 +21,14 @@ def initialize( created_at:, updated_at:, policy_id:, - size:, + size: nil, status:, - started_at:, + started_at: nil, migration_id:, services:, resources:, - resource_id:, - resource_type: + resource_id: nil, + resource_type: nil ) @id = id @created_at = created_at @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "policyId" => "", "status" => "", "migrationId" => "", "services" => [], "resources" => [] }.merge(map) BackupArchive.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/backup_archive_list.rb b/lib/appwrite/models/backup_archive_list.rb index 9c0cc7cc..848d268c 100644 --- a/lib/appwrite/models/backup_archive_list.rb +++ b/lib/appwrite/models/backup_archive_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "archives" => [] }.merge(map) BackupArchiveList.new( total: map["total"], archives: map["archives"].map { |it| BackupArchive.from(map: it) } diff --git a/lib/appwrite/models/backup_policy.rb b/lib/appwrite/models/backup_policy.rb index 6e8e0376..e2ab6025 100644 --- a/lib/appwrite/models/backup_policy.rb +++ b/lib/appwrite/models/backup_policy.rb @@ -23,8 +23,8 @@ def initialize( updated_at:, services:, resources:, - resource_id:, - resource_type:, + resource_id: nil, + resource_type: nil, retention:, schedule:, type:, @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "name" => "", "$createdAt" => "", "$updatedAt" => "", "services" => [], "resources" => [], "retention" => 1, "schedule" => "0 * * * *", "type" => "full", "enabled" => false }.merge(map) BackupPolicy.new( id: map["$id"], name: map["name"], diff --git a/lib/appwrite/models/backup_policy_list.rb b/lib/appwrite/models/backup_policy_list.rb index d5de4a5d..294aa8ca 100644 --- a/lib/appwrite/models/backup_policy_list.rb +++ b/lib/appwrite/models/backup_policy_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "policies" => [] }.merge(map) BackupPolicyList.new( total: map["total"], policies: map["policies"].map { |it| BackupPolicy.from(map: it) } diff --git a/lib/appwrite/models/backup_restoration.rb b/lib/appwrite/models/backup_restoration.rb index 61eb62f4..03d4e9cf 100644 --- a/lib/appwrite/models/backup_restoration.rb +++ b/lib/appwrite/models/backup_restoration.rb @@ -22,7 +22,7 @@ def initialize( archive_id:, policy_id:, status:, - started_at:, + started_at: nil, migration_id:, services:, resources:, @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "archiveId" => "", "policyId" => "", "status" => "", "migrationId" => "", "services" => [], "resources" => [], "options" => {} }.merge(map) BackupRestoration.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/backup_restoration_list.rb b/lib/appwrite/models/backup_restoration_list.rb index 671e135b..8f6fb521 100644 --- a/lib/appwrite/models/backup_restoration_list.rb +++ b/lib/appwrite/models/backup_restoration_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "restorations" => [] }.merge(map) BackupRestorationList.new( total: map["total"], restorations: map["restorations"].map { |it| BackupRestoration.from(map: it) } diff --git a/lib/appwrite/models/billing_limits.rb b/lib/appwrite/models/billing_limits.rb index ef61643b..8eefd941 100644 --- a/lib/appwrite/models/billing_limits.rb +++ b/lib/appwrite/models/billing_limits.rb @@ -13,14 +13,14 @@ class BillingLimits attr_reader :budget_limit def initialize( - bandwidth:, - storage:, - users:, - executions:, - gb_hours:, - image_transformations:, - auth_phone:, - budget_limit: + bandwidth: 0, + storage: 0, + users: 0, + executions: 0, + gb_hours: 0, + image_transformations: 0, + auth_phone: 0, + budget_limit: 0 ) @bandwidth = bandwidth @storage = storage diff --git a/lib/appwrite/models/billing_plan.rb b/lib/appwrite/models/billing_plan.rb index 2a5b6644..db6849f9 100644 --- a/lib/appwrite/models/billing_plan.rb +++ b/lib/appwrite/models/billing_plan.rb @@ -90,7 +90,7 @@ def initialize( storage:, image_transformations:, screenshots_generated:, - members:, + members: 0, webhooks:, waf_rules:, environments:, @@ -115,20 +115,20 @@ def initialize( topics:, auth_phone:, domains:, - activity_logs:, + activity_logs: 1, usage_logs:, - usage_logs_intervals:, - usage_aggregate_only_metrics:, + usage_logs_intervals: ["15m", "1h", "1d"], + usage_aggregate_only_metrics: [], project_inactivity_days:, alert_limit:, - usage:, + usage: nil, addons:, budget_cap_enabled:, custom_smtp:, email_branding:, requires_payment_method:, requires_billing_address:, - eligible_countries:, + eligible_countries: [], is_available:, self_service:, premium_support:, @@ -142,19 +142,19 @@ def initialize( supports_free_email_validation:, supports_corporate_email_validation:, supports_project_specific_roles:, - backups_enabled:, + backups_enabled: true, usage_per_project:, supported_addons:, - backup_policies:, + backup_policies: 0, deployment_size:, build_size:, functions_interval_minimum:, databases_allow_encrypt:, - limits:, + limits: nil, group:, - program:, + program: nil, database_compute_credit:, - dedicated_databases: + dedicated_databases: nil ) @id = id @name = name @@ -234,6 +234,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "name" => "", "desc" => "", "order" => 0, "price" => 0, "trial" => 0, "bandwidth" => 0, "storage" => 0, "imageTransformations" => 0, "screenshotsGenerated" => 0, "webhooks" => 0, "wafRules" => 0, "environments" => 0, "projects" => 0, "platforms" => 0, "users" => 0, "teams" => 0, "databases" => 0, "databasesReads" => 0, "databasesWrites" => 0, "databasesBatchSize" => 0, "buckets" => 0, "fileSize" => 0, "functions" => 0, "sites" => 0, "executions" => 0, "executionsRetentionCount" => 1000, "GBHours" => 0, "realtime" => 0, "realtimeMessages" => 0, "messages" => 0, "topics" => 0, "authPhone" => 0, "domains" => 0, "usageLogs" => 0, "projectInactivityDays" => 0, "alertLimit" => 80, "budgetCapEnabled" => false, "customSmtp" => false, "emailBranding" => false, "requiresPaymentMethod" => true, "requiresBillingAddress" => false, "isAvailable" => true, "selfService" => true, "premiumSupport" => true, "budgeting" => true, "supportsMockNumbers" => true, "supportsOrganizationRoles" => true, "supportsCredits" => false, "supportsDedicatedDatabases" => false, "supportsDisposableEmailValidation" => false, "supportsCanonicalEmailValidation" => false, "supportsFreeEmailValidation" => false, "supportsCorporateEmailValidation" => false, "supportsProjectSpecificRoles" => false, "usagePerProject" => true, "deploymentSize" => 0, "buildSize" => 0, "functionsIntervalMinimum" => 0, "databasesAllowEncrypt" => false, "databaseComputeCredit" => 0 }.merge(map) BillingPlan.new( id: map["$id"], name: map["name"], @@ -276,7 +277,7 @@ def self.from(map:) usage_aggregate_only_metrics: map["usageAggregateOnlyMetrics"], project_inactivity_days: map["projectInactivityDays"], alert_limit: map["alertLimit"], - usage: UsageBillingPlan.from(map: map["usage"]), + usage: map["usage"].nil? ? nil : UsageBillingPlan.from(map: map["usage"]), addons: BillingPlanAddon.from(map: map["addons"]), budget_cap_enabled: map["budgetCapEnabled"], custom_smtp: map["customSmtp"], @@ -356,7 +357,7 @@ def to_map "usageAggregateOnlyMetrics": @usage_aggregate_only_metrics, "projectInactivityDays": @project_inactivity_days, "alertLimit": @alert_limit, - "usage": @usage.to_map, + "usage": @usage&.to_map, "addons": @addons.to_map, "budgetCapEnabled": @budget_cap_enabled, "customSmtp": @custom_smtp, @@ -397,7 +398,6 @@ def to_map def validate_group(group) valid_group = [ - Appwrite::Enums::BillingPlanGroup::STARTER, Appwrite::Enums::BillingPlanGroup::FREE, Appwrite::Enums::BillingPlanGroup::START, Appwrite::Enums::BillingPlanGroup::PRO, diff --git a/lib/appwrite/models/billing_plan_addon.rb b/lib/appwrite/models/billing_plan_addon.rb index 3a24097e..c5017292 100644 --- a/lib/appwrite/models/billing_plan_addon.rb +++ b/lib/appwrite/models/billing_plan_addon.rb @@ -7,8 +7,8 @@ class BillingPlanAddon attr_reader :projects def initialize( - seats:, - projects: + seats: nil, + projects: nil ) @seats = seats @projects = projects diff --git a/lib/appwrite/models/billing_plan_addon_details.rb b/lib/appwrite/models/billing_plan_addon_details.rb index 3dc5e285..70e7f13c 100644 --- a/lib/appwrite/models/billing_plan_addon_details.rb +++ b/lib/appwrite/models/billing_plan_addon_details.rb @@ -17,7 +17,7 @@ def initialize( plan_included:, limit:, type:, - currency:, + currency: nil, price:, value:, invoice_desc: @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "supported" => false, "planIncluded" => 0, "limit" => 0, "type" => "numeric", "price" => 0, "value" => 0, "invoiceDesc" => "" }.merge(map) BillingPlanAddonDetails.new( supported: map["supported"], plan_included: map["planIncluded"], diff --git a/lib/appwrite/models/billing_plan_dedicated_database_limits.rb b/lib/appwrite/models/billing_plan_dedicated_database_limits.rb index 3e179ad2..a6c6bb7c 100644 --- a/lib/appwrite/models/billing_plan_dedicated_database_limits.rb +++ b/lib/appwrite/models/billing_plan_dedicated_database_limits.rb @@ -24,25 +24,25 @@ class BillingPlanDedicatedDatabaseLimits attr_reader :allowed_sync_modes def initialize( - min_cpu:, - max_cpu:, - min_memory_mb:, - max_memory_mb:, - min_storage_gb:, - max_storage_gb:, - max_replicas:, - max_connections:, - max_ip_allowlist_size:, - max_extensions:, - max_backup_retention_days:, - max_pitr_retention_days:, - max_sql_api_max_rows:, - max_sql_api_max_bytes:, - max_sql_api_timeout_seconds:, - max_sql_api_allowed_statements:, - allowed_sql_statements:, - allowed_storage_classes:, - allowed_sync_modes: + min_cpu: 0, + max_cpu: 0, + min_memory_mb: 0, + max_memory_mb: 0, + min_storage_gb: 0, + max_storage_gb: 0, + max_replicas: 0, + max_connections: 0, + max_ip_allowlist_size: 0, + max_extensions: 0, + max_backup_retention_days: 0, + max_pitr_retention_days: 0, + max_sql_api_max_rows: 0, + max_sql_api_max_bytes: 0, + max_sql_api_timeout_seconds: 0, + max_sql_api_allowed_statements: 0, + allowed_sql_statements: [], + allowed_storage_classes: [], + allowed_sync_modes: [] ) @min_cpu = min_cpu @max_cpu = max_cpu diff --git a/lib/appwrite/models/billing_plan_limits.rb b/lib/appwrite/models/billing_plan_limits.rb index 999a55bf..89f5235c 100644 --- a/lib/appwrite/models/billing_plan_limits.rb +++ b/lib/appwrite/models/billing_plan_limits.rb @@ -7,8 +7,8 @@ class BillingPlanLimits attr_reader :daily_credits def initialize( - credits:, - daily_credits: + credits: 0, + daily_credits: 0 ) @credits = credits @daily_credits = daily_credits diff --git a/lib/appwrite/models/billing_plan_supported_addons.rb b/lib/appwrite/models/billing_plan_supported_addons.rb index ea2d8078..430878ac 100644 --- a/lib/appwrite/models/billing_plan_supported_addons.rb +++ b/lib/appwrite/models/billing_plan_supported_addons.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "baa" => false, "premiumGeoDB" => false, "premiumGeoDBOrg" => false }.merge(map) BillingPlanSupportedAddons.new( baa: map["baa"], premium_geo_db: map["premiumGeoDB"], diff --git a/lib/appwrite/models/block.rb b/lib/appwrite/models/block.rb index 4a1c81a6..7525b796 100644 --- a/lib/appwrite/models/block.rb +++ b/lib/appwrite/models/block.rb @@ -7,53 +7,30 @@ class Block attr_reader :resource_type attr_reader :resource_id attr_reader :mode - attr_reader :reason attr_reader :expired_at - attr_reader :project_name - attr_reader :region - attr_reader :organization_name - attr_reader :organization_id - attr_reader :billing_plan def initialize( created_at:, resource_type:, resource_id:, mode:, - reason:, - expired_at:, - project_name:, - region:, - organization_name:, - organization_id:, - billing_plan: + expired_at: nil ) @created_at = created_at @resource_type = resource_type @resource_id = resource_id @mode = mode - @reason = reason @expired_at = expired_at - @project_name = project_name - @region = region - @organization_name = organization_name - @organization_id = organization_id - @billing_plan = billing_plan end def self.from(map:) + map = { "$createdAt" => "", "resourceType" => "", "resourceId" => "", "mode" => "full" }.merge(map) Block.new( created_at: map["$createdAt"], resource_type: map["resourceType"], resource_id: map["resourceId"], mode: map["mode"], - reason: map["reason"], - expired_at: map["expiredAt"], - project_name: map["projectName"], - region: map["region"], - organization_name: map["organizationName"], - organization_id: map["organizationId"], - billing_plan: map["billingPlan"] + expired_at: map["expiredAt"] ) end @@ -63,13 +40,7 @@ def to_map "resourceType": @resource_type, "resourceId": @resource_id, "mode": @mode, - "reason": @reason, - "expiredAt": @expired_at, - "projectName": @project_name, - "region": @region, - "organizationName": @organization_name, - "organizationId": @organization_id, - "billingPlan": @billing_plan + "expiredAt": @expired_at } end end diff --git a/lib/appwrite/models/bucket.rb b/lib/appwrite/models/bucket.rb index c7e8af99..4729a406 100644 --- a/lib/appwrite/models/bucket.rb +++ b/lib/appwrite/models/bucket.rb @@ -51,6 +51,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "fileSecurity" => false, "name" => "", "enabled" => true, "maximumFileSize" => 0, "allowedFileExtensions" => [], "compression" => "", "encryption" => true, "antivirus" => true, "transformations" => true, "totalSize" => 0 }.merge(map) Bucket.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/bucket_list.rb b/lib/appwrite/models/bucket_list.rb index 7d3c15a2..4912786b 100644 --- a/lib/appwrite/models/bucket_list.rb +++ b/lib/appwrite/models/bucket_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "buckets" => [] }.merge(map) BucketList.new( total: map["total"], buckets: map["buckets"].map { |it| Bucket.from(map: it) } diff --git a/lib/appwrite/models/collection.rb b/lib/appwrite/models/collection.rb index 9e270f29..d0319ddd 100644 --- a/lib/appwrite/models/collection.rb +++ b/lib/appwrite/models/collection.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "databaseId" => "", "name" => "", "enabled" => true, "documentSecurity" => false, "attributes" => [], "indexes" => [], "bytesMax" => 0, "bytesUsed" => 0 }.merge(map) Collection.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/collection_list.rb b/lib/appwrite/models/collection_list.rb index e1e42d26..31b8f1b8 100644 --- a/lib/appwrite/models/collection_list.rb +++ b/lib/appwrite/models/collection_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "collections" => [] }.merge(map) CollectionList.new( total: map["total"], collections: map["collections"].map { |it| Collection.from(map: it) } diff --git a/lib/appwrite/models/column_bigint.rb b/lib/appwrite/models/column_bigint.rb index 3dfa471a..5471695b 100644 --- a/lib/appwrite/models/column_bigint.rb +++ b/lib/appwrite/models/column_bigint.rb @@ -21,12 +21,12 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - min:, - max:, - default: + min: nil, + max: nil, + default: nil ) @key = key @type = type @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnBigint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_boolean.rb b/lib/appwrite/models/column_boolean.rb index 83baf4a5..3c956e9b 100644 --- a/lib/appwrite/models/column_boolean.rb +++ b/lib/appwrite/models/column_boolean.rb @@ -19,10 +19,10 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - default: + default: nil ) @key = key @type = type @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnBoolean.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_datetime.rb b/lib/appwrite/models/column_datetime.rb index 60122665..2f8f5225 100644 --- a/lib/appwrite/models/column_datetime.rb +++ b/lib/appwrite/models/column_datetime.rb @@ -20,11 +20,11 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, format:, - default: + default: nil ) @key = key @type = type @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnDatetime.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_email.rb b/lib/appwrite/models/column_email.rb index 574e47e5..e150190a 100644 --- a/lib/appwrite/models/column_email.rb +++ b/lib/appwrite/models/column_email.rb @@ -20,11 +20,11 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, format:, - default: + default: nil ) @key = key @type = type @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "email" }.merge(map) ColumnEmail.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_enum.rb b/lib/appwrite/models/column_enum.rb index 0f2bd545..a4f64ce2 100644 --- a/lib/appwrite/models/column_enum.rb +++ b/lib/appwrite/models/column_enum.rb @@ -21,12 +21,12 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, elements:, format:, - default: + default: nil ) @key = key @type = type @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "elements" => [], "format" => "enum" }.merge(map) ColumnEnum.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_float.rb b/lib/appwrite/models/column_float.rb index 3c06c690..c98c3fa9 100644 --- a/lib/appwrite/models/column_float.rb +++ b/lib/appwrite/models/column_float.rb @@ -21,12 +21,12 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - min:, - max:, - default: + min: nil, + max: nil, + default: nil ) @key = key @type = type @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnFloat.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_index.rb b/lib/appwrite/models/column_index.rb index 478d4c23..3b4f89bc 100644 --- a/lib/appwrite/models/column_index.rb +++ b/lib/appwrite/models/column_index.rb @@ -24,7 +24,7 @@ def initialize( error:, columns:, lengths:, - orders: + orders: [] ) @id = id @created_at = created_at @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "key" => "", "type" => "", "status" => "", "error" => "", "columns" => [], "lengths" => [] }.merge(map) ColumnIndex.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/column_index_list.rb b/lib/appwrite/models/column_index_list.rb index 9278fd40..5aacf564 100644 --- a/lib/appwrite/models/column_index_list.rb +++ b/lib/appwrite/models/column_index_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "indexes" => [] }.merge(map) ColumnIndexList.new( total: map["total"], indexes: map["indexes"].map { |it| ColumnIndex.from(map: it) } diff --git a/lib/appwrite/models/column_integer.rb b/lib/appwrite/models/column_integer.rb index 0a71c44f..283f25fb 100644 --- a/lib/appwrite/models/column_integer.rb +++ b/lib/appwrite/models/column_integer.rb @@ -21,12 +21,12 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - min:, - max:, - default: + min: nil, + max: nil, + default: nil ) @key = key @type = type @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnInteger.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_ip.rb b/lib/appwrite/models/column_ip.rb index 3d4f6551..6c19af85 100644 --- a/lib/appwrite/models/column_ip.rb +++ b/lib/appwrite/models/column_ip.rb @@ -20,11 +20,11 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, format:, - default: + default: nil ) @key = key @type = type @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "ip" }.merge(map) ColumnIp.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_line.rb b/lib/appwrite/models/column_line.rb index f8a14bf0..fb119a77 100644 --- a/lib/appwrite/models/column_line.rb +++ b/lib/appwrite/models/column_line.rb @@ -19,10 +19,10 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - default: + default: nil ) @key = key @type = type @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnLine.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_list.rb b/lib/appwrite/models/column_list.rb index 8d239ddf..a635a9b4 100644 --- a/lib/appwrite/models/column_list.rb +++ b/lib/appwrite/models/column_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "columns" => [] }.merge(map) ColumnList.new( total: map["total"], columns: map["columns"] diff --git a/lib/appwrite/models/column_longtext.rb b/lib/appwrite/models/column_longtext.rb index 5a112087..da120fad 100644 --- a/lib/appwrite/models/column_longtext.rb +++ b/lib/appwrite/models/column_longtext.rb @@ -20,11 +20,11 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - default:, - encrypt: + default: nil, + encrypt: false ) @key = key @type = type @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnLongtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_mediumtext.rb b/lib/appwrite/models/column_mediumtext.rb index c5b465c9..bc182bd9 100644 --- a/lib/appwrite/models/column_mediumtext.rb +++ b/lib/appwrite/models/column_mediumtext.rb @@ -20,11 +20,11 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - default:, - encrypt: + default: nil, + encrypt: false ) @key = key @type = type @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnMediumtext.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_point.rb b/lib/appwrite/models/column_point.rb index 34e5cf0e..5db63a70 100644 --- a/lib/appwrite/models/column_point.rb +++ b/lib/appwrite/models/column_point.rb @@ -19,10 +19,10 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - default: + default: nil ) @key = key @type = type @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnPoint.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_polygon.rb b/lib/appwrite/models/column_polygon.rb index 82f39732..c59c3eb8 100644 --- a/lib/appwrite/models/column_polygon.rb +++ b/lib/appwrite/models/column_polygon.rb @@ -19,10 +19,10 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - default: + default: nil ) @key = key @type = type @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnPolygon.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_relationship.rb b/lib/appwrite/models/column_relationship.rb index c34643ea..e59f6bb7 100644 --- a/lib/appwrite/models/column_relationship.rb +++ b/lib/appwrite/models/column_relationship.rb @@ -24,7 +24,7 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, related_table:, @@ -51,6 +51,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "relationType" => "", "twoWay" => false, "twoWayKey" => "", "onDelete" => "restrict", "side" => "" }.merge(map) ColumnRelationship.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_string.rb b/lib/appwrite/models/column_string.rb index 6e08f2f5..e9d112c5 100644 --- a/lib/appwrite/models/column_string.rb +++ b/lib/appwrite/models/column_string.rb @@ -21,12 +21,12 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, size:, - default:, - encrypt: + default: nil, + encrypt: false ) @key = key @type = type @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) ColumnString.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_text.rb b/lib/appwrite/models/column_text.rb index c3c7afb0..1660db2d 100644 --- a/lib/appwrite/models/column_text.rb +++ b/lib/appwrite/models/column_text.rb @@ -20,11 +20,11 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, - default:, - encrypt: + default: nil, + encrypt: false ) @key = key @type = type @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "" }.merge(map) ColumnText.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_url.rb b/lib/appwrite/models/column_url.rb index 11829a7d..3a4c6566 100644 --- a/lib/appwrite/models/column_url.rb +++ b/lib/appwrite/models/column_url.rb @@ -20,11 +20,11 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, format:, - default: + default: nil ) @key = key @type = type @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "format" => "url" }.merge(map) ColumnUrl.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/column_varchar.rb b/lib/appwrite/models/column_varchar.rb index 1a1083d7..57c2b571 100644 --- a/lib/appwrite/models/column_varchar.rb +++ b/lib/appwrite/models/column_varchar.rb @@ -21,12 +21,12 @@ def initialize( status:, error:, required:, - array:, + array: false, created_at:, updated_at:, size:, - default:, - encrypt: + default: nil, + encrypt: false ) @key = key @type = type @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "type" => "", "error" => "", "required" => false, "$createdAt" => "", "$updatedAt" => "", "size" => 0 }.merge(map) ColumnVarchar.new( key: map["key"], type: map["type"], diff --git a/lib/appwrite/models/continent.rb b/lib/appwrite/models/continent.rb index 861ec29f..64190bbc 100644 --- a/lib/appwrite/models/continent.rb +++ b/lib/appwrite/models/continent.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "code" => "" }.merge(map) Continent.new( name: map["name"], code: map["code"] diff --git a/lib/appwrite/models/continent_list.rb b/lib/appwrite/models/continent_list.rb index a5312493..f6a8c658 100644 --- a/lib/appwrite/models/continent_list.rb +++ b/lib/appwrite/models/continent_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "continents" => [] }.merge(map) ContinentList.new( total: map["total"], continents: map["continents"].map { |it| Continent.from(map: it) } diff --git a/lib/appwrite/models/country.rb b/lib/appwrite/models/country.rb index 07659799..7943e2cb 100644 --- a/lib/appwrite/models/country.rb +++ b/lib/appwrite/models/country.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "code" => "" }.merge(map) Country.new( name: map["name"], code: map["code"] diff --git a/lib/appwrite/models/country_list.rb b/lib/appwrite/models/country_list.rb index 1611dda7..7e537feb 100644 --- a/lib/appwrite/models/country_list.rb +++ b/lib/appwrite/models/country_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "countries" => [] }.merge(map) CountryList.new( total: map["total"], countries: map["countries"].map { |it| Country.from(map: it) } diff --git a/lib/appwrite/models/currency.rb b/lib/appwrite/models/currency.rb index b89e48ab..b9ebad26 100644 --- a/lib/appwrite/models/currency.rb +++ b/lib/appwrite/models/currency.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "symbol" => "", "name" => "", "symbolNative" => "", "decimalDigits" => 0, "rounding" => 0, "code" => "", "namePlural" => "" }.merge(map) Currency.new( symbol: map["symbol"], name: map["name"], diff --git a/lib/appwrite/models/currency_list.rb b/lib/appwrite/models/currency_list.rb index 53d23594..663aec21 100644 --- a/lib/appwrite/models/currency_list.rb +++ b/lib/appwrite/models/currency_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "currencies" => [] }.merge(map) CurrencyList.new( total: map["total"], currencies: map["currencies"].map { |it| Currency.from(map: it) } diff --git a/lib/appwrite/models/database.rb b/lib/appwrite/models/database.rb index d0408fc8..1db09df8 100644 --- a/lib/appwrite/models/database.rb +++ b/lib/appwrite/models/database.rb @@ -26,15 +26,15 @@ def initialize( updated_at:, enabled:, type:, - status:, - engine:, - specification:, - replicas:, - error:, - container_status:, - lifecycle_state:, - policies:, - archives: + status: nil, + engine: nil, + specification: nil, + replicas: nil, + error: nil, + container_status: nil, + lifecycle_state: nil, + policies: nil, + archives: nil ) @id = id @name = name @@ -54,6 +54,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "name" => "", "$createdAt" => "", "$updatedAt" => "", "enabled" => true, "type" => "legacy" }.merge(map) Database.new( id: map["$id"], name: map["name"], diff --git a/lib/appwrite/models/database_list.rb b/lib/appwrite/models/database_list.rb index 37c83aab..7b008d97 100644 --- a/lib/appwrite/models/database_list.rb +++ b/lib/appwrite/models/database_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "databases" => [] }.merge(map) DatabaseList.new( total: map["total"], databases: map["databases"].map { |it| Database.from(map: it) } diff --git a/lib/appwrite/models/database_migration.rb b/lib/appwrite/models/database_migration.rb index 75becc38..d0b4071d 100644 --- a/lib/appwrite/models/database_migration.rb +++ b/lib/appwrite/models/database_migration.rb @@ -60,6 +60,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "projectId" => "", "databaseId" => "", "specification" => "", "phase" => "pending", "attempt" => 0, "lastError" => "", "lagDocuments" => 0, "changelogWatermark" => 0, "verifiedAt" => "", "cutoverAt" => "", "soakUntil" => "", "autoCutover" => true, "cutoverRequested" => false, "paused" => false }.merge(map) DatabaseMigration.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/database_migration_list.rb b/lib/appwrite/models/database_migration_list.rb index 21730266..f42c1c2f 100644 --- a/lib/appwrite/models/database_migration_list.rb +++ b/lib/appwrite/models/database_migration_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "migrations" => [] }.merge(map) DatabaseMigrationList.new( total: map["total"], migrations: map["migrations"].map { |it| DatabaseMigration.from(map: it) } diff --git a/lib/appwrite/models/database_status.rb b/lib/appwrite/models/database_status.rb index f4a609c1..377292a1 100644 --- a/lib/appwrite/models/database_status.rb +++ b/lib/appwrite/models/database_status.rb @@ -24,13 +24,13 @@ def initialize( engine:, version:, uptime:, - connections:, + connections: nil, sync_mode:, - effective_sync_mode:, + effective_sync_mode: nil, sync_degraded:, sync_acknowledgements:, sync_standby_count:, - sync_state_confirmed:, + sync_state_confirmed: nil, replicas:, volumes: ) @@ -51,13 +51,14 @@ def initialize( end def self.from(map:) + map = { "health" => "unknown", "ready" => false, "engine" => "postgresql", "version" => "", "uptime" => 0, "syncMode" => "async", "syncDegraded" => false, "syncAcknowledgements" => 0, "syncStandbyCount" => 0, "replicas" => [], "volumes" => [] }.merge(map) DatabaseStatus.new( health: map["health"], ready: map["ready"], engine: map["engine"], version: map["version"], uptime: map["uptime"], - connections: DatabaseStatusConnections.from(map: map["connections"]), + connections: map["connections"].nil? ? nil : DatabaseStatusConnections.from(map: map["connections"]), sync_mode: map["syncMode"], effective_sync_mode: map["effectiveSyncMode"], sync_degraded: map["syncDegraded"], @@ -76,7 +77,7 @@ def to_map "engine": @engine, "version": @version, "uptime": @uptime, - "connections": @connections.to_map, + "connections": @connections&.to_map, "syncMode": @sync_mode, "effectiveSyncMode": @effective_sync_mode, "syncDegraded": @sync_degraded, diff --git a/lib/appwrite/models/database_status_connections.rb b/lib/appwrite/models/database_status_connections.rb index 623156df..22104215 100644 --- a/lib/appwrite/models/database_status_connections.rb +++ b/lib/appwrite/models/database_status_connections.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "current" => 0, "max" => 100 }.merge(map) DatabaseStatusConnections.new( current: map["current"], max: map["max"] diff --git a/lib/appwrite/models/database_status_replica.rb b/lib/appwrite/models/database_status_replica.rb index 7ed53873..da0292d8 100644 --- a/lib/appwrite/models/database_status_replica.rb +++ b/lib/appwrite/models/database_status_replica.rb @@ -13,8 +13,8 @@ def initialize( index:, role:, healthy:, - replicating:, - lag_seconds: + replicating: nil, + lag_seconds: nil ) @index = index @role = role @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "index" => 0, "role" => "unknown", "healthy" => false }.merge(map) DatabaseStatusReplica.new( index: map["index"], role: map["role"], diff --git a/lib/appwrite/models/database_status_volume.rb b/lib/appwrite/models/database_status_volume.rb index cd15505b..03c314eb 100644 --- a/lib/appwrite/models/database_status_volume.rb +++ b/lib/appwrite/models/database_status_volume.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "path" => "", "usedPercent" => "0%", "available" => "0GB", "mounted" => false }.merge(map) DatabaseStatusVolume.new( xpath: map["path"], used_percent: map["usedPercent"], diff --git a/lib/appwrite/models/dedicated_database.rb b/lib/appwrite/models/dedicated_database.rb index ca683b57..aaa6a30d 100644 --- a/lib/appwrite/models/dedicated_database.rb +++ b/lib/appwrite/models/dedicated_database.rb @@ -62,22 +62,22 @@ def initialize( updated_at:, project_id:, name:, - api:, - engine:, + api: nil, + engine: nil, version:, specification:, backend:, hostname:, - connection_port:, + connection_port: nil, connection_user:, connection_password:, - credential_generation:, + credential_generation: nil, connection_string:, ssl:, status:, container_status:, - last_accessed_at:, - idle_until:, + last_accessed_at: nil, + idle_until: nil, lifecycle_state:, idle_timeout_minutes:, cpu:, @@ -85,7 +85,7 @@ def initialize( storage:, storage_status:, storage_target_gb:, - storage_resize_started_at:, + storage_resize_started_at: nil, storage_class:, storage_max_gb:, node_pool:, @@ -165,6 +165,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "projectId" => "", "name" => "", "version" => "", "specification" => "", "backend" => "", "hostname" => "", "connectionUser" => "", "connectionPassword" => "", "connectionString" => "", "ssl" => false, "status" => "provisioning", "containerStatus" => "", "lifecycleState" => "", "idleTimeoutMinutes" => 15, "cpu" => 500, "memory" => 512, "storage" => 10, "storageStatus" => "idle", "storageTargetGb" => 0, "storageClass" => "ssd", "storageMaxGb" => 0, "nodePool" => "", "replicas" => 0, "syncMode" => "", "networkMaxConnections" => 100, "networkIdleTimeoutSeconds" => 900, "networkIPAllowlist" => [], "backupEnabled" => true, "pitr" => true, "pitrRetentionDays" => 7, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, "storageAutoscalingMaxGb" => 0, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => false, "sqlApiEnabled" => true, "sqlApiAllowedStatements" => ["SELECT", "INSERT", "UPDATE", "DELETE"], "sqlApiMaxRows" => 10000, "sqlApiMaxBytes" => 10485760, "sqlApiTimeoutSeconds" => 30, "error" => "" }.merge(map) DedicatedDatabase.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/dedicated_database_backup.rb b/lib/appwrite/models/dedicated_database_backup.rb index f48b5d58..daaeb678 100644 --- a/lib/appwrite/models/dedicated_database_backup.rb +++ b/lib/appwrite/models/dedicated_database_backup.rb @@ -33,11 +33,11 @@ def initialize( fallback_reason:, status:, size_bytes:, - started_at:, - completed_at:, - verified_at:, - expires_at:, - log_position:, + started_at: nil, + completed_at: nil, + verified_at: nil, + expires_at: nil, + log_position: nil, error: ) @id = id @@ -60,6 +60,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "databaseId" => "", "projectId" => "", "policyId" => "", "trigger" => "manual", "type" => "full", "requestedType" => "", "fallbackReason" => "", "status" => "pending", "sizeBytes" => 0, "error" => "" }.merge(map) DedicatedDatabaseBackup.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/dedicated_database_backup_list.rb b/lib/appwrite/models/dedicated_database_backup_list.rb index 37d85ec0..c2c02187 100644 --- a/lib/appwrite/models/dedicated_database_backup_list.rb +++ b/lib/appwrite/models/dedicated_database_backup_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "backups" => [] }.merge(map) DedicatedDatabaseBackupList.new( total: map["total"], backups: map["backups"].map { |it| DedicatedDatabaseBackup.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_backup_storage.rb b/lib/appwrite/models/dedicated_database_backup_storage.rb index 3e1cb28b..aa2f1a2b 100644 --- a/lib/appwrite/models/dedicated_database_backup_storage.rb +++ b/lib/appwrite/models/dedicated_database_backup_storage.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "provider" => "", "bucket" => "", "region" => "", "prefix" => "backups/", "endpoint" => "" }.merge(map) DedicatedDatabaseBackupStorage.new( provider: map["provider"], bucket: map["bucket"], diff --git a/lib/appwrite/models/dedicated_database_branch.rb b/lib/appwrite/models/dedicated_database_branch.rb index 991728ca..0cd2e314 100644 --- a/lib/appwrite/models/dedicated_database_branch.rb +++ b/lib/appwrite/models/dedicated_database_branch.rb @@ -22,7 +22,7 @@ def initialize( namespace:, expires_at:, host:, - port:, + port: nil, database:, username:, password:, @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "branchId" => "", "branchName" => "", "namespace" => "", "expiresAt" => 0, "host" => "", "database" => "", "username" => "", "password" => "", "ssl" => false, "engine" => "", "connectionString" => "" }.merge(map) DedicatedDatabaseBranch.new( branch_id: map["branchId"], branch_name: map["branchName"], diff --git a/lib/appwrite/models/dedicated_database_branch_list.rb b/lib/appwrite/models/dedicated_database_branch_list.rb index 106a3eb7..9ce8a978 100644 --- a/lib/appwrite/models/dedicated_database_branch_list.rb +++ b/lib/appwrite/models/dedicated_database_branch_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "branches" => [] }.merge(map) DedicatedDatabaseBranchList.new( total: map["total"], branches: map["branches"].map { |it| DedicatedDatabaseBranch.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_execution.rb b/lib/appwrite/models/dedicated_database_execution.rb index 49e247f3..8422db2d 100644 --- a/lib/appwrite/models/dedicated_database_execution.rb +++ b/lib/appwrite/models/dedicated_database_execution.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "rows" => [], "rowCount" => 0, "columns" => [], "durationMs" => 0, "truncated" => false, "bytes" => 0 }.merge(map) DedicatedDatabaseExecution.new( rows: map["rows"], row_count: map["rowCount"], diff --git a/lib/appwrite/models/dedicated_database_execution_column.rb b/lib/appwrite/models/dedicated_database_execution_column.rb index 4605650d..735dd40e 100644 --- a/lib/appwrite/models/dedicated_database_execution_column.rb +++ b/lib/appwrite/models/dedicated_database_execution_column.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "type" => "" }.merge(map) DedicatedDatabaseExecutionColumn.new( name: map["name"], type: map["type"] diff --git a/lib/appwrite/models/dedicated_database_extensions.rb b/lib/appwrite/models/dedicated_database_extensions.rb index 26c35a8e..559e09c2 100644 --- a/lib/appwrite/models/dedicated_database_extensions.rb +++ b/lib/appwrite/models/dedicated_database_extensions.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "installed" => [], "available" => [], "metadata" => [] }.merge(map) DedicatedDatabaseExtensions.new( installed: map["installed"], available: map["available"], diff --git a/lib/appwrite/models/dedicated_database_list.rb b/lib/appwrite/models/dedicated_database_list.rb index 3a66c939..79b8e45a 100644 --- a/lib/appwrite/models/dedicated_database_list.rb +++ b/lib/appwrite/models/dedicated_database_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "databases" => [] }.merge(map) DedicatedDatabaseList.new( total: map["total"], databases: map["databases"].map { |it| DedicatedDatabase.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_member.rb b/lib/appwrite/models/dedicated_database_member.rb index 8aaddc77..a5aa07d5 100644 --- a/lib/appwrite/models/dedicated_database_member.rb +++ b/lib/appwrite/models/dedicated_database_member.rb @@ -13,8 +13,8 @@ def initialize( id:, role:, status:, - replicating:, - lag_seconds: + replicating: nil, + lag_seconds: nil ) @id = id @role = role @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "role" => "unknown", "status" => "" }.merge(map) DedicatedDatabaseMember.new( id: map["$id"], role: map["role"], diff --git a/lib/appwrite/models/dedicated_database_operation.rb b/lib/appwrite/models/dedicated_database_operation.rb index bd6b53cf..2cef5df7 100644 --- a/lib/appwrite/models/dedicated_database_operation.rb +++ b/lib/appwrite/models/dedicated_database_operation.rb @@ -22,9 +22,9 @@ def initialize( type:, status:, attempts:, - requested_at:, - started_at:, - completed_at:, + requested_at: nil, + started_at: nil, + completed_at: nil, error_code:, error_message: ) @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "databaseId" => "", "type" => "", "status" => "", "attempts" => 0, "errorCode" => "", "errorMessage" => "" }.merge(map) DedicatedDatabaseOperation.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/dedicated_database_operation_list.rb b/lib/appwrite/models/dedicated_database_operation_list.rb index d4985739..8b63a84b 100644 --- a/lib/appwrite/models/dedicated_database_operation_list.rb +++ b/lib/appwrite/models/dedicated_database_operation_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "operations" => [] }.merge(map) DedicatedDatabaseOperationList.new( total: map["total"], operations: map["operations"].map { |it| DedicatedDatabaseOperation.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_pitr_windows.rb b/lib/appwrite/models/dedicated_database_pitr_windows.rb index b80d115d..492f5bac 100644 --- a/lib/appwrite/models/dedicated_database_pitr_windows.rb +++ b/lib/appwrite/models/dedicated_database_pitr_windows.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "earliest" => "", "latest" => "" }.merge(map) DedicatedDatabasePITRWindows.new( earliest: map["earliest"], latest: map["latest"] diff --git a/lib/appwrite/models/dedicated_database_pooler.rb b/lib/appwrite/models/dedicated_database_pooler.rb index a87c1776..1804c09c 100644 --- a/lib/appwrite/models/dedicated_database_pooler.rb +++ b/lib/appwrite/models/dedicated_database_pooler.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => false, "mode" => "transaction", "maxConnections" => 100, "defaultPoolSize" => 20, "port" => 6432, "readWriteSplitting" => false, "poolerCpuRequest" => "", "poolerCpuLimit" => "", "poolerMemoryRequest" => "", "poolerMemoryLimit" => "" }.merge(map) DedicatedDatabasePooler.new( enabled: map["enabled"], mode: map["mode"], diff --git a/lib/appwrite/models/dedicated_database_replicas.rb b/lib/appwrite/models/dedicated_database_replicas.rb index 72106776..68ea5e41 100644 --- a/lib/appwrite/models/dedicated_database_replicas.rb +++ b/lib/appwrite/models/dedicated_database_replicas.rb @@ -15,11 +15,11 @@ class DedicatedDatabaseReplicas def initialize( replicas:, sync_mode:, - effective_sync_mode:, + effective_sync_mode: nil, sync_degraded:, sync_acknowledgements:, sync_standby_count:, - sync_state_confirmed:, + sync_state_confirmed: nil, members: ) @replicas = replicas @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "replicas" => 0, "syncMode" => "async", "syncDegraded" => false, "syncAcknowledgements" => 0, "syncStandbyCount" => 0, "members" => [] }.merge(map) DedicatedDatabaseReplicas.new( replicas: map["replicas"], sync_mode: map["syncMode"], diff --git a/lib/appwrite/models/dedicated_database_restoration.rb b/lib/appwrite/models/dedicated_database_restoration.rb index be6e9f26..5bcbd807 100644 --- a/lib/appwrite/models/dedicated_database_restoration.rb +++ b/lib/appwrite/models/dedicated_database_restoration.rb @@ -10,6 +10,7 @@ class DedicatedDatabaseRestoration attr_reader :project_id attr_reader :backup_id attr_reader :type + attr_reader :restore_mode attr_reader :status attr_reader :target_time attr_reader :started_at @@ -20,14 +21,15 @@ def initialize( id:, created_at:, database_id:, - source_database_id:, + source_database_id: nil, project_id:, - backup_id:, + backup_id: nil, type:, + restore_mode:, status:, - target_time:, - started_at:, - completed_at:, + target_time: nil, + started_at: nil, + completed_at: nil, error: ) @id = id @@ -37,6 +39,7 @@ def initialize( @project_id = project_id @backup_id = backup_id @type = type + @restore_mode = restore_mode @status = status @target_time = target_time @started_at = started_at @@ -45,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "databaseId" => "", "projectId" => "", "type" => "backup", "restoreMode" => "in_place", "status" => "pending", "error" => "" }.merge(map) DedicatedDatabaseRestoration.new( id: map["$id"], created_at: map["$createdAt"], @@ -53,6 +57,7 @@ def self.from(map:) project_id: map["projectId"], backup_id: map["backupId"], type: map["type"], + restore_mode: map["restoreMode"], status: map["status"], target_time: map["targetTime"], started_at: map["startedAt"], @@ -70,6 +75,7 @@ def to_map "projectId": @project_id, "backupId": @backup_id, "type": @type, + "restoreMode": @restore_mode, "status": @status, "targetTime": @target_time, "startedAt": @started_at, diff --git a/lib/appwrite/models/dedicated_database_restoration_list.rb b/lib/appwrite/models/dedicated_database_restoration_list.rb index dcb3f9ee..7755ec27 100644 --- a/lib/appwrite/models/dedicated_database_restoration_list.rb +++ b/lib/appwrite/models/dedicated_database_restoration_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "restorations" => [] }.merge(map) DedicatedDatabaseRestorationList.new( total: map["total"], restorations: map["restorations"].map { |it| DedicatedDatabaseRestoration.from(map: it) } diff --git a/lib/appwrite/models/dedicated_database_specification.rb b/lib/appwrite/models/dedicated_database_specification.rb index b5f26a33..2c0bc719 100644 --- a/lib/appwrite/models/dedicated_database_specification.rb +++ b/lib/appwrite/models/dedicated_database_specification.rb @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "slug" => "", "name" => "", "price" => 0, "storageOverageRate" => 0, "bandwidthOverageRate" => 0, "replicaRate" => 0, "pitrRate" => 0, "cpu" => 0, "memory" => 0, "maxConnections" => 0, "includedStorage" => 0, "includedBandwidth" => 0, "enabled" => false }.merge(map) DedicatedDatabaseSpecification.new( slug: map["slug"], name: map["name"], diff --git a/lib/appwrite/models/dedicated_database_specification_list.rb b/lib/appwrite/models/dedicated_database_specification_list.rb index 206eec28..e649aa18 100644 --- a/lib/appwrite/models/dedicated_database_specification_list.rb +++ b/lib/appwrite/models/dedicated_database_specification_list.rb @@ -5,31 +5,27 @@ module Models class DedicatedDatabaseSpecificationList attr_reader :specifications attr_reader :total - attr_reader :pricing def initialize( specifications:, - total:, - pricing: + total: ) @specifications = specifications @total = total - @pricing = pricing end def self.from(map:) + map = { "specifications" => [], "total" => 0 }.merge(map) DedicatedDatabaseSpecificationList.new( specifications: map["specifications"].map { |it| DedicatedDatabaseSpecification.from(map: it) }, - total: map["total"], - pricing: DedicatedDatabaseSpecificationPricing.from(map: map["pricing"]) + total: map["total"] ) end def to_map { "specifications": @specifications.map { |it| it.to_map }, - "total": @total, - "pricing": @pricing.to_map + "total": @total } end end diff --git a/lib/appwrite/models/dedicated_database_specification_pricing.rb b/lib/appwrite/models/dedicated_database_specification_pricing.rb deleted file mode 100644 index d6ef0ef8..00000000 --- a/lib/appwrite/models/dedicated_database_specification_pricing.rb +++ /dev/null @@ -1,42 +0,0 @@ -# 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 :pitr_rate - - def initialize( - storage_overage_rate:, - bandwidth_overage_rate:, - replica_rate:, - pitr_rate: - ) - @storage_overage_rate = storage_overage_rate - @bandwidth_overage_rate = bandwidth_overage_rate - @replica_rate = 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"], - pitr_rate: map["pitrRate"] - ) - end - - def to_map - { - "storageOverageRate": @storage_overage_rate, - "bandwidthOverageRate": @bandwidth_overage_rate, - "replicaRate": @replica_rate, - "pitrRate": @pitr_rate - } - end - end - end -end diff --git a/lib/appwrite/models/deployment.rb b/lib/appwrite/models/deployment.rb index 6fc3465b..c4749311 100644 --- a/lib/appwrite/models/deployment.rb +++ b/lib/appwrite/models/deployment.rb @@ -90,6 +90,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "type" => "", "resourceId" => "", "resourceType" => "", "entrypoint" => "", "sourceSize" => 0, "buildSize" => 0, "totalSize" => 0, "buildId" => "", "activate" => false, "screenshotLight" => "", "screenshotDark" => "", "buildLogs" => "", "buildDuration" => 0, "providerRepositoryName" => "", "providerRepositoryOwner" => "", "providerRepositoryUrl" => "", "providerCommitHash" => "", "providerCommitAuthorUrl" => "", "providerCommitAuthor" => "", "providerCommitMessage" => "", "providerCommitUrl" => "", "providerBranch" => "", "providerBranchUrl" => "" }.merge(map) Deployment.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/deployment_list.rb b/lib/appwrite/models/deployment_list.rb index f9a2d696..5ff996f5 100644 --- a/lib/appwrite/models/deployment_list.rb +++ b/lib/appwrite/models/deployment_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "deployments" => [] }.merge(map) DeploymentList.new( total: map["total"], deployments: map["deployments"].map { |it| Deployment.from(map: it) } diff --git a/lib/appwrite/models/dev_key.rb b/lib/appwrite/models/dev_key.rb deleted file mode 100644 index 4389e82a..00000000 --- a/lib/appwrite/models/dev_key.rb +++ /dev/null @@ -1,62 +0,0 @@ -# frozen_string_literal: true - -module Appwrite - module Models - class DevKey - attr_reader :id - attr_reader :created_at - attr_reader :updated_at - attr_reader :name - attr_reader :expire - attr_reader :secret - attr_reader :accessed_at - attr_reader :sdks - - def initialize( - id:, - created_at:, - updated_at:, - name:, - expire:, - secret:, - accessed_at:, - sdks: - ) - @id = id - @created_at = created_at - @updated_at = updated_at - @name = name - @expire = expire - @secret = secret - @accessed_at = accessed_at - @sdks = sdks - end - - def self.from(map:) - DevKey.new( - id: map["$id"], - created_at: map["$createdAt"], - updated_at: map["$updatedAt"], - name: map["name"], - expire: map["expire"], - secret: map["secret"], - accessed_at: map["accessedAt"], - sdks: map["sdks"] - ) - end - - def to_map - { - "$id": @id, - "$createdAt": @created_at, - "$updatedAt": @updated_at, - "name": @name, - "expire": @expire, - "secret": @secret, - "accessedAt": @accessed_at, - "sdks": @sdks - } - end - end - end -end diff --git a/lib/appwrite/models/document.rb b/lib/appwrite/models/document.rb index 0cc8a466..02ed60e3 100644 --- a/lib/appwrite/models/document.rb +++ b/lib/appwrite/models/document.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$sequence" => "", "$collectionId" => "", "$databaseId" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [] }.merge(map) Document.new( id: map["$id"], sequence: map["$sequence"], diff --git a/lib/appwrite/models/document_list.rb b/lib/appwrite/models/document_list.rb index 254e19e2..9a1c4f69 100644 --- a/lib/appwrite/models/document_list.rb +++ b/lib/appwrite/models/document_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "documents" => [] }.merge(map) DocumentList.new( total: map["total"], documents: map["documents"].map { |it| Document.from(map: it) } diff --git a/lib/appwrite/models/domain.rb b/lib/appwrite/models/domain.rb index dda43a3a..67fd4961 100644 --- a/lib/appwrite/models/domain.rb +++ b/lib/appwrite/models/domain.rb @@ -28,7 +28,7 @@ def initialize( renewal:, auto_renewal:, renewal_price:, - transfer_status:, + transfer_status: nil, team_id:, dns_records: ) diff --git a/lib/appwrite/models/domain_price.rb b/lib/appwrite/models/domain_price.rb index c67f7263..1618b129 100644 --- a/lib/appwrite/models/domain_price.rb +++ b/lib/appwrite/models/domain_price.rb @@ -16,10 +16,10 @@ def initialize( domain:, tld:, available:, - price:, + price: nil, period_years:, premium:, - renewal_price:, + renewal_price: nil, renewal_period_years: ) @domain = domain diff --git a/lib/appwrite/models/email_template.rb b/lib/appwrite/models/email_template.rb index 5cacd768..ee13cfb6 100644 --- a/lib/appwrite/models/email_template.rb +++ b/lib/appwrite/models/email_template.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "templateId" => "", "locale" => "", "message" => "", "senderName" => "", "senderEmail" => "", "replyToEmail" => "", "replyToName" => "", "subject" => "" }.merge(map) EmailTemplate.new( template_id: map["templateId"], locale: map["locale"], diff --git a/lib/appwrite/models/email_template_list.rb b/lib/appwrite/models/email_template_list.rb index fbc649f1..4334c55c 100644 --- a/lib/appwrite/models/email_template_list.rb +++ b/lib/appwrite/models/email_template_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "templates" => [] }.merge(map) EmailTemplateList.new( total: map["total"], templates: map["templates"].map { |it| EmailTemplate.from(map: it) } diff --git a/lib/appwrite/models/embedding.rb b/lib/appwrite/models/embedding.rb index 177a94f4..f7c9978d 100644 --- a/lib/appwrite/models/embedding.rb +++ b/lib/appwrite/models/embedding.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "model" => "", "dimension" => 0, "embedding" => [], "error" => "" }.merge(map) Embedding.new( model: map["model"], dimension: map["dimension"], diff --git a/lib/appwrite/models/embedding_list.rb b/lib/appwrite/models/embedding_list.rb index 848b50d4..10090e93 100644 --- a/lib/appwrite/models/embedding_list.rb +++ b/lib/appwrite/models/embedding_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "embeddings" => [] }.merge(map) EmbeddingList.new( total: map["total"], embeddings: map["embeddings"].map { |it| Embedding.from(map: it) } diff --git a/lib/appwrite/models/ephemeral_key.rb b/lib/appwrite/models/ephemeral_key.rb index 14761c4f..cdc9eb77 100644 --- a/lib/appwrite/models/ephemeral_key.rb +++ b/lib/appwrite/models/ephemeral_key.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "expire" => "", "scopes" => [], "secret" => "", "accessedAt" => "", "sdks" => [] }.merge(map) EphemeralKey.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/execution.rb b/lib/appwrite/models/execution.rb index 55a701d5..f78e38c9 100644 --- a/lib/appwrite/models/execution.rb +++ b/lib/appwrite/models/execution.rb @@ -42,7 +42,7 @@ def initialize( logs:, errors:, duration:, - scheduled_at: + scheduled_at: nil ) @id = id @created_at = created_at @@ -66,6 +66,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "resourceId" => "", "resourceType" => "functions", "deploymentId" => "", "requestMethod" => "", "requestPath" => "", "requestHeaders" => [], "responseStatusCode" => 0, "responseBody" => "", "responseHeaders" => [], "logs" => "", "errors" => "", "duration" => 0 }.merge(map) Execution.new( id: map["$id"], created_at: map["$createdAt"], @@ -133,6 +134,7 @@ def validate_trigger(trigger) Appwrite::Enums::ExecutionTrigger::HTTP, Appwrite::Enums::ExecutionTrigger::SCHEDULE, Appwrite::Enums::ExecutionTrigger::EVENT, + Appwrite::Enums::ExecutionTrigger::EMAIL, ] unless valid_trigger.include?(trigger) diff --git a/lib/appwrite/models/execution_list.rb b/lib/appwrite/models/execution_list.rb index 531551db..457400c3 100644 --- a/lib/appwrite/models/execution_list.rb +++ b/lib/appwrite/models/execution_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "executions" => [] }.merge(map) ExecutionList.new( total: map["total"], executions: map["executions"].map { |it| Execution.from(map: it) } diff --git a/lib/appwrite/models/file.rb b/lib/appwrite/models/file.rb index 66ee936b..d448ece2 100644 --- a/lib/appwrite/models/file.rb +++ b/lib/appwrite/models/file.rb @@ -57,6 +57,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "bucketId" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "name" => "", "folder" => "", "key" => "", "signature" => "", "mimeType" => "", "sizeOriginal" => 0, "sizeActual" => 0, "chunksTotal" => 0, "chunksUploaded" => 0, "encryption" => false, "compression" => "none" }.merge(map) File.new( id: map["$id"], bucket_id: map["bucketId"], diff --git a/lib/appwrite/models/file_list.rb b/lib/appwrite/models/file_list.rb index 7a033d5a..9aee37f8 100644 --- a/lib/appwrite/models/file_list.rb +++ b/lib/appwrite/models/file_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "files" => [] }.merge(map) FileList.new( total: map["total"], files: map["files"].map { |it| File.from(map: it) } diff --git a/lib/appwrite/models/framework.rb b/lib/appwrite/models/framework.rb index 98108bfe..4dcc1d52 100644 --- a/lib/appwrite/models/framework.rb +++ b/lib/appwrite/models/framework.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "name" => "", "buildRuntime" => "", "runtimes" => [], "adapters" => [] }.merge(map) Framework.new( key: map["key"], name: map["name"], diff --git a/lib/appwrite/models/framework_adapter.rb b/lib/appwrite/models/framework_adapter.rb index 81d06e20..89588101 100644 --- a/lib/appwrite/models/framework_adapter.rb +++ b/lib/appwrite/models/framework_adapter.rb @@ -14,7 +14,7 @@ def initialize( install_command:, build_command:, output_directory:, - fallback_file: + fallback_file: nil ) @key = key @install_command = install_command @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "installCommand" => "", "buildCommand" => "", "outputDirectory" => "" }.merge(map) FrameworkAdapter.new( key: map["key"], install_command: map["installCommand"], diff --git a/lib/appwrite/models/framework_list.rb b/lib/appwrite/models/framework_list.rb index da86b56d..7f477fe7 100644 --- a/lib/appwrite/models/framework_list.rb +++ b/lib/appwrite/models/framework_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "frameworks" => [] }.merge(map) FrameworkList.new( total: map["total"], frameworks: map["frameworks"].map { |it| Framework.from(map: it) } diff --git a/lib/appwrite/models/function.rb b/lib/appwrite/models/function.rb index 6d8b38b7..a4475942 100644 --- a/lib/appwrite/models/function.rb +++ b/lib/appwrite/models/function.rb @@ -36,6 +36,7 @@ class Function attr_reader :provider_paths attr_reader :build_specification attr_reader :runtime_specification + attr_reader :email_enabled def initialize( id:, @@ -57,7 +58,7 @@ def initialize( vars:, events:, schedule:, - interval:, + interval: 0, timeout:, entrypoint:, commands:, @@ -70,7 +71,8 @@ def initialize( provider_branches:, provider_paths:, build_specification:, - runtime_specification: + runtime_specification:, + email_enabled: ) @id = id @created_at = created_at @@ -105,9 +107,11 @@ def initialize( @provider_paths = provider_paths @build_specification = build_specification @runtime_specification = runtime_specification + @email_enabled = email_enabled end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "execute" => [], "name" => "", "enabled" => true, "live" => true, "logging" => true, "runtime" => "", "deploymentRetention" => 0, "deploymentId" => "", "deploymentCreatedAt" => "", "latestDeploymentId" => "", "latestDeploymentCreatedAt" => "", "latestDeploymentStatus" => "", "scopes" => [], "vars" => [], "events" => [], "schedule" => "", "timeout" => 15, "entrypoint" => "", "commands" => "", "version" => "v5", "installationId" => "", "providerRepositoryId" => "", "providerBranch" => "", "providerRootDirectory" => "", "providerSilentMode" => false, "providerBranches" => [], "providerPaths" => [], "buildSpecification" => "s-1vcpu-512mb", "runtimeSpecification" => "s-1vcpu-512mb", "emailEnabled" => false }.merge(map) Function.new( id: map["$id"], created_at: map["$createdAt"], @@ -141,7 +145,8 @@ def self.from(map:) provider_branches: map["providerBranches"], provider_paths: map["providerPaths"], build_specification: map["buildSpecification"], - runtime_specification: map["runtimeSpecification"] + runtime_specification: map["runtimeSpecification"], + email_enabled: map["emailEnabled"] ) end @@ -179,7 +184,8 @@ def to_map "providerBranches": @provider_branches, "providerPaths": @provider_paths, "buildSpecification": @build_specification, - "runtimeSpecification": @runtime_specification + "runtimeSpecification": @runtime_specification, + "emailEnabled": @email_enabled } end end diff --git a/lib/appwrite/models/function_list.rb b/lib/appwrite/models/function_list.rb index 8ac71cf1..554fdeb2 100644 --- a/lib/appwrite/models/function_list.rb +++ b/lib/appwrite/models/function_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "functions" => [] }.merge(map) FunctionList.new( total: map["total"], functions: map["functions"].map { |it| Function.from(map: it) } diff --git a/lib/appwrite/models/headers.rb b/lib/appwrite/models/headers.rb index 5c43bea8..270773e3 100644 --- a/lib/appwrite/models/headers.rb +++ b/lib/appwrite/models/headers.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "value" => "" }.merge(map) Headers.new( name: map["name"], value: map["value"] diff --git a/lib/appwrite/models/identity.rb b/lib/appwrite/models/identity.rb index abf586a2..4261f302 100644 --- a/lib/appwrite/models/identity.rb +++ b/lib/appwrite/models/identity.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "provider" => "", "providerUid" => "", "providerEmail" => "", "providerAccessToken" => "", "providerAccessTokenExpiry" => "", "providerRefreshToken" => "", "providerIdToken" => "" }.merge(map) Identity.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/identity_list.rb b/lib/appwrite/models/identity_list.rb index bef444be..18d48d2f 100644 --- a/lib/appwrite/models/identity_list.rb +++ b/lib/appwrite/models/identity_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "identities" => [] }.merge(map) IdentityList.new( total: map["total"], identities: map["identities"].map { |it| Identity.from(map: it) } diff --git a/lib/appwrite/models/index.rb b/lib/appwrite/models/index.rb index 20b6e62b..da063ec1 100644 --- a/lib/appwrite/models/index.rb +++ b/lib/appwrite/models/index.rb @@ -24,7 +24,7 @@ def initialize( error:, attributes:, lengths:, - orders: + orders: [] ) @id = id @created_at = created_at @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "key" => "", "type" => "", "error" => "", "attributes" => [], "lengths" => [] }.merge(map) Index.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/index_list.rb b/lib/appwrite/models/index_list.rb index a0795d16..a096b0c2 100644 --- a/lib/appwrite/models/index_list.rb +++ b/lib/appwrite/models/index_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "indexes" => [] }.merge(map) IndexList.new( total: map["total"], indexes: map["indexes"].map { |it| Index.from(map: it) } diff --git a/lib/appwrite/models/insight.rb b/lib/appwrite/models/insight.rb index a10df160..01064bd1 100644 --- a/lib/appwrite/models/insight.rb +++ b/lib/appwrite/models/insight.rb @@ -36,9 +36,9 @@ def initialize( title:, summary:, ctas:, - analyzed_at:, - dismissed_at:, - dismissed_by: + analyzed_at: nil, + dismissed_at: nil, + dismissed_by: nil ) @id = id @created_at = created_at @@ -60,6 +60,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "reportId" => "", "type" => "", "severity" => "info", "status" => "active", "resourceType" => "", "resourceId" => "", "parentResourceType" => "", "parentResourceId" => "", "title" => "", "summary" => "", "ctas" => [] }.merge(map) Insight.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/insight_cta.rb b/lib/appwrite/models/insight_cta.rb index 36670cbe..1a92a732 100644 --- a/lib/appwrite/models/insight_cta.rb +++ b/lib/appwrite/models/insight_cta.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "label" => "", "service" => "", "method" => "", "params" => {} }.merge(map) InsightCTA.new( label: map["label"], service: map["service"], diff --git a/lib/appwrite/models/insight_list.rb b/lib/appwrite/models/insight_list.rb index af19aa84..70a1285b 100644 --- a/lib/appwrite/models/insight_list.rb +++ b/lib/appwrite/models/insight_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "insights" => [] }.merge(map) InsightList.new( total: map["total"], insights: map["insights"].map { |it| Insight.from(map: it) } diff --git a/lib/appwrite/models/jwt.rb b/lib/appwrite/models/jwt.rb index 73d8c92c..af1e7eb8 100644 --- a/lib/appwrite/models/jwt.rb +++ b/lib/appwrite/models/jwt.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "jwt" => "" }.merge(map) Jwt.new( jwt: map["jwt"] ) diff --git a/lib/appwrite/models/key.rb b/lib/appwrite/models/key.rb index 4df47cf3..5eb79318 100644 --- a/lib/appwrite/models/key.rb +++ b/lib/appwrite/models/key.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "expire" => "", "scopes" => [], "secret" => "", "accessedAt" => "", "sdks" => [] }.merge(map) Key.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/key_list.rb b/lib/appwrite/models/key_list.rb index d7a9649f..ac413cff 100644 --- a/lib/appwrite/models/key_list.rb +++ b/lib/appwrite/models/key_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "keys" => [] }.merge(map) KeyList.new( total: map["total"], keys: map["keys"].map { |it| Key.from(map: it) } diff --git a/lib/appwrite/models/language.rb b/lib/appwrite/models/language.rb index 8850a69b..b2acb8d8 100644 --- a/lib/appwrite/models/language.rb +++ b/lib/appwrite/models/language.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "name" => "", "code" => "", "nativeName" => "" }.merge(map) Language.new( name: map["name"], code: map["code"], diff --git a/lib/appwrite/models/language_list.rb b/lib/appwrite/models/language_list.rb index 118fc410..ec55d81e 100644 --- a/lib/appwrite/models/language_list.rb +++ b/lib/appwrite/models/language_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "languages" => [] }.merge(map) LanguageList.new( total: map["total"], languages: map["languages"].map { |it| Language.from(map: it) } diff --git a/lib/appwrite/models/locale.rb b/lib/appwrite/models/locale.rb index a31aea64..815f83c9 100644 --- a/lib/appwrite/models/locale.rb +++ b/lib/appwrite/models/locale.rb @@ -30,17 +30,17 @@ def initialize( continent:, eu:, currency:, - city:, - time_zone:, - postal_code:, - latitude:, - longitude:, - autonomous_system_number:, - autonomous_system_organization:, - isp:, - connection_type:, - connection_usage_type:, - connection_organization: + city: nil, + time_zone: nil, + postal_code: nil, + latitude: nil, + longitude: nil, + autonomous_system_number: nil, + autonomous_system_organization: nil, + isp: nil, + connection_type: nil, + connection_usage_type: nil, + connection_organization: nil ) @ip = ip @country_code = country_code @@ -63,6 +63,7 @@ def initialize( end def self.from(map:) + map = { "ip" => "", "countryCode" => "", "country" => "", "continentCode" => "", "continent" => "", "eu" => false, "currency" => "" }.merge(map) Locale.new( ip: map["ip"], country_code: map["countryCode"], diff --git a/lib/appwrite/models/locale_code.rb b/lib/appwrite/models/locale_code.rb index 6089272b..4795135c 100644 --- a/lib/appwrite/models/locale_code.rb +++ b/lib/appwrite/models/locale_code.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "code" => "", "name" => "" }.merge(map) LocaleCode.new( code: map["code"], name: map["name"] diff --git a/lib/appwrite/models/locale_code_list.rb b/lib/appwrite/models/locale_code_list.rb index b93213cb..e771b6d7 100644 --- a/lib/appwrite/models/locale_code_list.rb +++ b/lib/appwrite/models/locale_code_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "localeCodes" => [] }.merge(map) LocaleCodeList.new( total: map["total"], locale_codes: map["localeCodes"].map { |it| LocaleCode.from(map: it) } diff --git a/lib/appwrite/models/log.rb b/lib/appwrite/models/log.rb deleted file mode 100644 index 89e1a676..00000000 --- a/lib/appwrite/models/log.rb +++ /dev/null @@ -1,132 +0,0 @@ -# frozen_string_literal: true - -module Appwrite - module Models - class Log - attr_reader :event - attr_reader :user_id - attr_reader :user_email - attr_reader :user_name - attr_reader :mode - attr_reader :user_type - attr_reader :ip - attr_reader :time - attr_reader :os_code - attr_reader :os_name - attr_reader :os_version - attr_reader :client_type - attr_reader :client_code - attr_reader :client_name - attr_reader :client_version - attr_reader :client_engine - attr_reader :client_engine_version - attr_reader :device_name - attr_reader :device_brand - attr_reader :device_model - attr_reader :country_code - attr_reader :country_name - - def initialize( - event:, - user_id:, - user_email:, - user_name:, - mode:, - user_type:, - ip:, - time:, - os_code:, - os_name:, - os_version:, - client_type:, - client_code:, - client_name:, - client_version:, - client_engine:, - client_engine_version:, - device_name:, - device_brand:, - device_model:, - country_code:, - country_name: - ) - @event = event - @user_id = user_id - @user_email = user_email - @user_name = user_name - @mode = mode - @user_type = user_type - @ip = ip - @time = time - @os_code = os_code - @os_name = os_name - @os_version = os_version - @client_type = client_type - @client_code = client_code - @client_name = client_name - @client_version = client_version - @client_engine = client_engine - @client_engine_version = client_engine_version - @device_name = device_name - @device_brand = device_brand - @device_model = device_model - @country_code = country_code - @country_name = country_name - end - - def self.from(map:) - Log.new( - event: map["event"], - user_id: map["userId"], - user_email: map["userEmail"], - user_name: map["userName"], - mode: map["mode"], - user_type: map["userType"], - ip: map["ip"], - time: map["time"], - os_code: map["osCode"], - os_name: map["osName"], - os_version: map["osVersion"], - client_type: map["clientType"], - client_code: map["clientCode"], - client_name: map["clientName"], - client_version: map["clientVersion"], - client_engine: map["clientEngine"], - client_engine_version: map["clientEngineVersion"], - device_name: map["deviceName"], - device_brand: map["deviceBrand"], - device_model: map["deviceModel"], - country_code: map["countryCode"], - country_name: map["countryName"] - ) - end - - def to_map - { - "event": @event, - "userId": @user_id, - "userEmail": @user_email, - "userName": @user_name, - "mode": @mode, - "userType": @user_type, - "ip": @ip, - "time": @time, - "osCode": @os_code, - "osName": @os_name, - "osVersion": @os_version, - "clientType": @client_type, - "clientCode": @client_code, - "clientName": @client_name, - "clientVersion": @client_version, - "clientEngine": @client_engine, - "clientEngineVersion": @client_engine_version, - "deviceName": @device_name, - "deviceBrand": @device_brand, - "deviceModel": @device_model, - "countryCode": @country_code, - "countryName": @country_name - } - end - end - end -end diff --git a/lib/appwrite/models/log_list.rb b/lib/appwrite/models/log_list.rb deleted file mode 100644 index cdad965e..00000000 --- a/lib/appwrite/models/log_list.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -module Appwrite - module Models - class LogList - attr_reader :total - attr_reader :logs - - def initialize( - total:, - logs: - ) - @total = total - @logs = logs - end - - def self.from(map:) - LogList.new( - total: map["total"], - logs: map["logs"].map { |it| Log.from(map: it) } - ) - end - - def to_map - { - "total": @total, - "logs": @logs.map { |it| it.to_map } - } - end - end - end -end diff --git a/lib/appwrite/models/membership.rb b/lib/appwrite/models/membership.rb index 84b3ce1f..61e20c1d 100644 --- a/lib/appwrite/models/membership.rb +++ b/lib/appwrite/models/membership.rb @@ -54,6 +54,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "userName" => "", "userEmail" => "", "userPhone" => "", "teamId" => "", "teamName" => "", "invited" => "", "joined" => "", "confirm" => false, "mfa" => false, "userAccessedAt" => "", "roles" => [] }.merge(map) Membership.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/membership_list.rb b/lib/appwrite/models/membership_list.rb index 0cc220c0..dceb8db0 100644 --- a/lib/appwrite/models/membership_list.rb +++ b/lib/appwrite/models/membership_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "memberships" => [] }.merge(map) MembershipList.new( total: map["total"], memberships: map["memberships"].map { |it| Membership.from(map: it) } diff --git a/lib/appwrite/models/message.rb b/lib/appwrite/models/message.rb index 456afe3a..96d29512 100644 --- a/lib/appwrite/models/message.rb +++ b/lib/appwrite/models/message.rb @@ -25,9 +25,9 @@ def initialize( topics:, users:, targets:, - scheduled_at:, - delivered_at:, - delivery_errors:, + scheduled_at: nil, + delivered_at: nil, + delivery_errors: nil, delivered_total:, data:, status: @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "providerType" => "", "topics" => [], "users" => [], "targets" => [], "deliveredTotal" => 0, "data" => {}, "status" => "draft" }.merge(map) Message.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/message_list.rb b/lib/appwrite/models/message_list.rb index 50175444..d3930021 100644 --- a/lib/appwrite/models/message_list.rb +++ b/lib/appwrite/models/message_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "messages" => [] }.merge(map) MessageList.new( total: map["total"], messages: map["messages"].map { |it| Message.from(map: it) } diff --git a/lib/appwrite/models/mfa_challenge.rb b/lib/appwrite/models/mfa_challenge.rb index 6ba21fef..384f9031 100644 --- a/lib/appwrite/models/mfa_challenge.rb +++ b/lib/appwrite/models/mfa_challenge.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "expire" => "" }.merge(map) MfaChallenge.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/mfa_challenge_secret.rb b/lib/appwrite/models/mfa_challenge_secret.rb index ad8abbcd..36cb2e7d 100644 --- a/lib/appwrite/models/mfa_challenge_secret.rb +++ b/lib/appwrite/models/mfa_challenge_secret.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "expire" => "", "code" => "" }.merge(map) MfaChallengeSecret.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/mfa_factors.rb b/lib/appwrite/models/mfa_factors.rb index 55b58ca2..55db99ea 100644 --- a/lib/appwrite/models/mfa_factors.rb +++ b/lib/appwrite/models/mfa_factors.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "totp" => false, "phone" => false, "email" => false, "recoveryCode" => false, "custom" => false }.merge(map) MfaFactors.new( totp: map["totp"], phone: map["phone"], diff --git a/lib/appwrite/models/mfa_recovery_codes.rb b/lib/appwrite/models/mfa_recovery_codes.rb index 1fd53c11..c9097acb 100644 --- a/lib/appwrite/models/mfa_recovery_codes.rb +++ b/lib/appwrite/models/mfa_recovery_codes.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "recoveryCodes" => [] }.merge(map) MfaRecoveryCodes.new( recovery_codes: map["recoveryCodes"] ) diff --git a/lib/appwrite/models/mfa_type.rb b/lib/appwrite/models/mfa_type.rb index 0612dc2d..4a8c7482 100644 --- a/lib/appwrite/models/mfa_type.rb +++ b/lib/appwrite/models/mfa_type.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "secret" => "", "uri" => "" }.merge(map) MfaType.new( secret: map["secret"], uri: map["uri"] diff --git a/lib/appwrite/models/mock_number.rb b/lib/appwrite/models/mock_number.rb index 59d96f27..8bb41c9b 100644 --- a/lib/appwrite/models/mock_number.rb +++ b/lib/appwrite/models/mock_number.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "number" => "", "otp" => "", "$createdAt" => "", "$updatedAt" => "" }.merge(map) MockNumber.new( number: map["number"], otp: map["otp"], diff --git a/lib/appwrite/models/mock_number_list.rb b/lib/appwrite/models/mock_number_list.rb index 56a7fdd2..ca3a9af1 100644 --- a/lib/appwrite/models/mock_number_list.rb +++ b/lib/appwrite/models/mock_number_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "mockNumbers" => [] }.merge(map) MockNumberList.new( total: map["total"], mock_numbers: map["mockNumbers"].map { |it| MockNumber.from(map: it) } diff --git a/lib/appwrite/models/o_auth2_amazon.rb b/lib/appwrite/models/o_auth2_amazon.rb index 177ce121..1afa9f98 100644 --- a/lib/appwrite/models/o_auth2_amazon.rb +++ b/lib/appwrite/models/o_auth2_amazon.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Amazon.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_apple.rb b/lib/appwrite/models/o_auth2_apple.rb index f5949d06..ed1b5058 100644 --- a/lib/appwrite/models/o_auth2_apple.rb +++ b/lib/appwrite/models/o_auth2_apple.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "serviceId" => "", "keyId" => "", "teamId" => "", "p8File" => "", "nativeEnabled" => false, "nativeClientIds" => [] }.merge(map) OAuth2Apple.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_appwrite.rb b/lib/appwrite/models/o_auth2_appwrite.rb index c12a6b55..e9624285 100644 --- a/lib/appwrite/models/o_auth2_appwrite.rb +++ b/lib/appwrite/models/o_auth2_appwrite.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Appwrite.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_auth0.rb b/lib/appwrite/models/o_auth2_auth0.rb index e9cf3cb0..0625fe06 100644 --- a/lib/appwrite/models/o_auth2_auth0.rb +++ b/lib/appwrite/models/o_auth2_auth0.rb @@ -22,11 +22,12 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) @endpoint = endpoint end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [], "endpoint" => "" }.merge(map) OAuth2Auth0.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_authentik.rb b/lib/appwrite/models/o_auth2_authentik.rb index 81fc7ff8..643597f5 100644 --- a/lib/appwrite/models/o_auth2_authentik.rb +++ b/lib/appwrite/models/o_auth2_authentik.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "endpoint" => "" }.merge(map) OAuth2Authentik.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_autodesk.rb b/lib/appwrite/models/o_auth2_autodesk.rb index f260b12e..fa2a8d98 100644 --- a/lib/appwrite/models/o_auth2_autodesk.rb +++ b/lib/appwrite/models/o_auth2_autodesk.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Autodesk.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_bitbucket.rb b/lib/appwrite/models/o_auth2_bitbucket.rb index 44509504..f4686ebc 100644 --- a/lib/appwrite/models/o_auth2_bitbucket.rb +++ b/lib/appwrite/models/o_auth2_bitbucket.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "key" => "", "secret" => "" }.merge(map) OAuth2Bitbucket.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_bitly.rb b/lib/appwrite/models/o_auth2_bitly.rb index ad116ed0..a9efb469 100644 --- a/lib/appwrite/models/o_auth2_bitly.rb +++ b/lib/appwrite/models/o_auth2_bitly.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Bitly.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_box.rb b/lib/appwrite/models/o_auth2_box.rb index 7cdfedd0..e2aa2269 100644 --- a/lib/appwrite/models/o_auth2_box.rb +++ b/lib/appwrite/models/o_auth2_box.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Box.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_cloudflare.rb b/lib/appwrite/models/o_auth2_cloudflare.rb index 7f3e65bf..f0bc5549 100644 --- a/lib/appwrite/models/o_auth2_cloudflare.rb +++ b/lib/appwrite/models/o_auth2_cloudflare.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Cloudflare.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_dailymotion.rb b/lib/appwrite/models/o_auth2_dailymotion.rb index 31e10ed1..241d92c7 100644 --- a/lib/appwrite/models/o_auth2_dailymotion.rb +++ b/lib/appwrite/models/o_auth2_dailymotion.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "apiKey" => "", "apiSecret" => "" }.merge(map) OAuth2Dailymotion.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_discord.rb b/lib/appwrite/models/o_auth2_discord.rb index 5d7db0cb..972672bd 100644 --- a/lib/appwrite/models/o_auth2_discord.rb +++ b/lib/appwrite/models/o_auth2_discord.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [] }.merge(map) OAuth2Discord.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_disqus.rb b/lib/appwrite/models/o_auth2_disqus.rb index 2b8e4261..e1670515 100644 --- a/lib/appwrite/models/o_auth2_disqus.rb +++ b/lib/appwrite/models/o_auth2_disqus.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "publicKey" => "", "secretKey" => "" }.merge(map) OAuth2Disqus.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_dropbox.rb b/lib/appwrite/models/o_auth2_dropbox.rb index d5581312..d57c294d 100644 --- a/lib/appwrite/models/o_auth2_dropbox.rb +++ b/lib/appwrite/models/o_auth2_dropbox.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "appKey" => "", "appSecret" => "" }.merge(map) OAuth2Dropbox.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_etsy.rb b/lib/appwrite/models/o_auth2_etsy.rb index 87acab75..2af4595a 100644 --- a/lib/appwrite/models/o_auth2_etsy.rb +++ b/lib/appwrite/models/o_auth2_etsy.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "keyString" => "", "sharedSecret" => "" }.merge(map) OAuth2Etsy.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_facebook.rb b/lib/appwrite/models/o_auth2_facebook.rb index f42ab1e7..6a6206de 100644 --- a/lib/appwrite/models/o_auth2_facebook.rb +++ b/lib/appwrite/models/o_auth2_facebook.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "appId" => "", "appSecret" => "" }.merge(map) OAuth2Facebook.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_figma.rb b/lib/appwrite/models/o_auth2_figma.rb index 7da8c796..2470388c 100644 --- a/lib/appwrite/models/o_auth2_figma.rb +++ b/lib/appwrite/models/o_auth2_figma.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Figma.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_fusion_auth.rb b/lib/appwrite/models/o_auth2_fusion_auth.rb index 74e205e3..28bf8307 100644 --- a/lib/appwrite/models/o_auth2_fusion_auth.rb +++ b/lib/appwrite/models/o_auth2_fusion_auth.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "endpoint" => "" }.merge(map) OAuth2FusionAuth.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_github.rb b/lib/appwrite/models/o_auth2_github.rb index d46e1e38..66986a27 100644 --- a/lib/appwrite/models/o_auth2_github.rb +++ b/lib/appwrite/models/o_auth2_github.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [] }.merge(map) OAuth2Github.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_gitlab.rb b/lib/appwrite/models/o_auth2_gitlab.rb index 2f1d2237..5a7b7f5b 100644 --- a/lib/appwrite/models/o_auth2_gitlab.rb +++ b/lib/appwrite/models/o_auth2_gitlab.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "applicationId" => "", "secret" => "", "endpoint" => "" }.merge(map) OAuth2Gitlab.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_google.rb b/lib/appwrite/models/o_auth2_google.rb index b646c30d..be1959fd 100644 --- a/lib/appwrite/models/o_auth2_google.rb +++ b/lib/appwrite/models/o_auth2_google.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => ["consent"], "nativeEnabled" => false, "nativeClientIds" => [] }.merge(map) OAuth2Google.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_hugging_face.rb b/lib/appwrite/models/o_auth2_hugging_face.rb index c75e13cc..43430cb0 100644 --- a/lib/appwrite/models/o_auth2_hugging_face.rb +++ b/lib/appwrite/models/o_auth2_hugging_face.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2HuggingFace.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_keycloak.rb b/lib/appwrite/models/o_auth2_keycloak.rb index 6af51b90..3e432d14 100644 --- a/lib/appwrite/models/o_auth2_keycloak.rb +++ b/lib/appwrite/models/o_auth2_keycloak.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "endpoint" => "", "realmName" => "" }.merge(map) OAuth2Keycloak.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_kick.rb b/lib/appwrite/models/o_auth2_kick.rb index eb5c8092..1d764fa3 100644 --- a/lib/appwrite/models/o_auth2_kick.rb +++ b/lib/appwrite/models/o_auth2_kick.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Kick.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_linkedin.rb b/lib/appwrite/models/o_auth2_linkedin.rb index 8b91b062..bcac2a97 100644 --- a/lib/appwrite/models/o_auth2_linkedin.rb +++ b/lib/appwrite/models/o_auth2_linkedin.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "primaryClientSecret" => "" }.merge(map) OAuth2Linkedin.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_microsoft.rb b/lib/appwrite/models/o_auth2_microsoft.rb index 29c2cb1e..4525c54c 100644 --- a/lib/appwrite/models/o_auth2_microsoft.rb +++ b/lib/appwrite/models/o_auth2_microsoft.rb @@ -22,11 +22,12 @@ def initialize( @enabled = enabled @application_id = application_id @application_secret = application_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) @tenant = tenant end def self.from(map:) + map = { "$id" => "", "enabled" => false, "applicationId" => "", "applicationSecret" => "", "prompt" => [], "tenant" => "" }.merge(map) OAuth2Microsoft.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_notion.rb b/lib/appwrite/models/o_auth2_notion.rb index 3382c410..1869df5b 100644 --- a/lib/appwrite/models/o_auth2_notion.rb +++ b/lib/appwrite/models/o_auth2_notion.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "oauthClientId" => "", "oauthClientSecret" => "" }.merge(map) OAuth2Notion.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_oidc.rb b/lib/appwrite/models/o_auth2_oidc.rb index a034231b..5b018ce1 100644 --- a/lib/appwrite/models/o_auth2_oidc.rb +++ b/lib/appwrite/models/o_auth2_oidc.rb @@ -7,11 +7,11 @@ class OAuth2Oidc attr_reader :enabled attr_reader :client_id attr_reader :client_secret + attr_reader :prompt attr_reader :well_known_url attr_reader :authorization_url attr_reader :token_url attr_reader :user_info_url - attr_reader :prompt attr_reader :max_age def initialize( @@ -19,36 +19,37 @@ def initialize( enabled:, client_id:, client_secret:, + prompt:, well_known_url:, authorization_url:, token_url:, user_info_url:, - prompt:, - max_age: + max_age: nil ) @id = id @enabled = enabled @client_id = client_id @client_secret = client_secret + @prompt = validate_prompt(prompt) @well_known_url = well_known_url @authorization_url = authorization_url @token_url = token_url @user_info_url = user_info_url - @prompt = validate_prompt(prompt) @max_age = max_age end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [], "wellKnownURL" => "", "authorizationURL" => "", "tokenURL" => "", "userInfoURL" => "" }.merge(map) OAuth2Oidc.new( id: map["$id"], enabled: map["enabled"], client_id: map["clientId"], client_secret: map["clientSecret"], + prompt: map["prompt"], well_known_url: map["wellKnownURL"], authorization_url: map["authorizationURL"], token_url: map["tokenURL"], user_info_url: map["userInfoURL"], - prompt: map["prompt"], max_age: map["maxAge"] ) end @@ -59,11 +60,11 @@ def to_map "enabled": @enabled, "clientId": @client_id, "clientSecret": @client_secret, + "prompt": @prompt, "wellKnownURL": @well_known_url, "authorizationURL": @authorization_url, "tokenURL": @token_url, "userInfoURL": @user_info_url, - "prompt": @prompt, "maxAge": @max_age } end diff --git a/lib/appwrite/models/o_auth2_okta.rb b/lib/appwrite/models/o_auth2_okta.rb index 11d5746f..4abfdd09 100644 --- a/lib/appwrite/models/o_auth2_okta.rb +++ b/lib/appwrite/models/o_auth2_okta.rb @@ -24,12 +24,13 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) @domain = domain @authorization_server_id = authorization_server_id end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [], "domain" => "", "authorizationServerId" => "" }.merge(map) OAuth2Okta.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_paypal.rb b/lib/appwrite/models/o_auth2_paypal.rb index 32263b46..27db8cdd 100644 --- a/lib/appwrite/models/o_auth2_paypal.rb +++ b/lib/appwrite/models/o_auth2_paypal.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "secretKey" => "" }.merge(map) OAuth2Paypal.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_podio.rb b/lib/appwrite/models/o_auth2_podio.rb index d1efea82..f25f60e2 100644 --- a/lib/appwrite/models/o_auth2_podio.rb +++ b/lib/appwrite/models/o_auth2_podio.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Podio.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_provider_list.rb b/lib/appwrite/models/o_auth2_provider_list.rb index 16bdbbaf..40596466 100644 --- a/lib/appwrite/models/o_auth2_provider_list.rb +++ b/lib/appwrite/models/o_auth2_provider_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "providers" => [] }.merge(map) OAuth2ProviderList.new( total: map["total"], providers: map["providers"] diff --git a/lib/appwrite/models/o_auth2_resend.rb b/lib/appwrite/models/o_auth2_resend.rb index 9a64087d..86084bde 100644 --- a/lib/appwrite/models/o_auth2_resend.rb +++ b/lib/appwrite/models/o_auth2_resend.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Resend.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_salesforce.rb b/lib/appwrite/models/o_auth2_salesforce.rb index 0cd7bc78..0a3ae31a 100644 --- a/lib/appwrite/models/o_auth2_salesforce.rb +++ b/lib/appwrite/models/o_auth2_salesforce.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @customer_key = customer_key @customer_secret = customer_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "customerKey" => "", "customerSecret" => "", "prompt" => [] }.merge(map) OAuth2Salesforce.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_slack.rb b/lib/appwrite/models/o_auth2_slack.rb index 209cc3b5..149cd400 100644 --- a/lib/appwrite/models/o_auth2_slack.rb +++ b/lib/appwrite/models/o_auth2_slack.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Slack.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_spotify.rb b/lib/appwrite/models/o_auth2_spotify.rb index 014d82dc..addf5467 100644 --- a/lib/appwrite/models/o_auth2_spotify.rb +++ b/lib/appwrite/models/o_auth2_spotify.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Spotify.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_stripe.rb b/lib/appwrite/models/o_auth2_stripe.rb index 66604406..4b580c06 100644 --- a/lib/appwrite/models/o_auth2_stripe.rb +++ b/lib/appwrite/models/o_auth2_stripe.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "apiSecretKey" => "" }.merge(map) OAuth2Stripe.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_tradeshift.rb b/lib/appwrite/models/o_auth2_tradeshift.rb index 749c666d..5099f337 100644 --- a/lib/appwrite/models/o_auth2_tradeshift.rb +++ b/lib/appwrite/models/o_auth2_tradeshift.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "oauth2ClientId" => "", "oauth2ClientSecret" => "" }.merge(map) OAuth2Tradeshift.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_twitch.rb b/lib/appwrite/models/o_auth2_twitch.rb index ac7fa8a1..b2f90f4e 100644 --- a/lib/appwrite/models/o_auth2_twitch.rb +++ b/lib/appwrite/models/o_auth2_twitch.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Twitch.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_word_press.rb b/lib/appwrite/models/o_auth2_word_press.rb index 3fab755c..9453b756 100644 --- a/lib/appwrite/models/o_auth2_word_press.rb +++ b/lib/appwrite/models/o_auth2_word_press.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2WordPress.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_x.rb b/lib/appwrite/models/o_auth2_x.rb index d2f771a4..55b32ea6 100644 --- a/lib/appwrite/models/o_auth2_x.rb +++ b/lib/appwrite/models/o_auth2_x.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "customerKey" => "", "secretKey" => "" }.merge(map) OAuth2X.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_yahoo.rb b/lib/appwrite/models/o_auth2_yahoo.rb index 13aea493..1d0819e1 100644 --- a/lib/appwrite/models/o_auth2_yahoo.rb +++ b/lib/appwrite/models/o_auth2_yahoo.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Yahoo.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_yandex.rb b/lib/appwrite/models/o_auth2_yandex.rb index 8373037e..102e0bf4 100644 --- a/lib/appwrite/models/o_auth2_yandex.rb +++ b/lib/appwrite/models/o_auth2_yandex.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Yandex.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_zoho.rb b/lib/appwrite/models/o_auth2_zoho.rb index 792da041..c7bb5db2 100644 --- a/lib/appwrite/models/o_auth2_zoho.rb +++ b/lib/appwrite/models/o_auth2_zoho.rb @@ -20,10 +20,11 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret - @prompt = prompt.nil? ? prompt : validate_prompt(prompt) + @prompt = validate_prompt(prompt) end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [] }.merge(map) OAuth2Zoho.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/o_auth2_zoom.rb b/lib/appwrite/models/o_auth2_zoom.rb index d7b261ce..97617c2b 100644 --- a/lib/appwrite/models/o_auth2_zoom.rb +++ b/lib/appwrite/models/o_auth2_zoom.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) OAuth2Zoom.new( id: map["$id"], enabled: map["enabled"], diff --git a/lib/appwrite/models/oauth2_approve.rb b/lib/appwrite/models/oauth2_approve.rb index 748c7880..32e7f309 100644 --- a/lib/appwrite/models/oauth2_approve.rb +++ b/lib/appwrite/models/oauth2_approve.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "redirectUrl" => "" }.merge(map) Oauth2Approve.new( redirect_url: map["redirectUrl"] ) diff --git a/lib/appwrite/models/oauth2_authorize.rb b/lib/appwrite/models/oauth2_authorize.rb index 99f35e8c..269932a6 100644 --- a/lib/appwrite/models/oauth2_authorize.rb +++ b/lib/appwrite/models/oauth2_authorize.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "grantId" => "", "redirectUrl" => "" }.merge(map) Oauth2Authorize.new( grant_id: map["grantId"], redirect_url: map["redirectUrl"] diff --git a/lib/appwrite/models/oauth2_consent.rb b/lib/appwrite/models/oauth2_consent.rb index af8f3ec0..f1080bca 100644 --- a/lib/appwrite/models/oauth2_consent.rb +++ b/lib/appwrite/models/oauth2_consent.rb @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "appId" => "", "cimdUrl" => "", "scopes" => [], "resources" => [], "authorizationDetails" => "[]", "expire" => "" }.merge(map) Oauth2Consent.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/oauth2_consent_list.rb b/lib/appwrite/models/oauth2_consent_list.rb index a6ca3cea..7543e968 100644 --- a/lib/appwrite/models/oauth2_consent_list.rb +++ b/lib/appwrite/models/oauth2_consent_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "consents" => [] }.merge(map) Oauth2ConsentList.new( total: map["total"], consents: map["consents"].map { |it| Oauth2Consent.from(map: it) } diff --git a/lib/appwrite/models/oauth2_consent_token.rb b/lib/appwrite/models/oauth2_consent_token.rb index 6b1bc02a..bc01ac00 100644 --- a/lib/appwrite/models/oauth2_consent_token.rb +++ b/lib/appwrite/models/oauth2_consent_token.rb @@ -42,6 +42,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "consentId" => "", "userId" => "", "appId" => "", "cimdUrl" => "", "scopes" => [], "resources" => [], "authorizationDetails" => "[]", "expire" => "" }.merge(map) Oauth2ConsentToken.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/oauth2_consent_token_list.rb b/lib/appwrite/models/oauth2_consent_token_list.rb index edf5aef9..efcc0a05 100644 --- a/lib/appwrite/models/oauth2_consent_token_list.rb +++ b/lib/appwrite/models/oauth2_consent_token_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "tokens" => [] }.merge(map) Oauth2ConsentTokenList.new( total: map["total"], tokens: map["tokens"].map { |it| Oauth2ConsentToken.from(map: it) } diff --git a/lib/appwrite/models/oauth2_device_authorization.rb b/lib/appwrite/models/oauth2_device_authorization.rb index 428970ac..86c07de1 100644 --- a/lib/appwrite/models/oauth2_device_authorization.rb +++ b/lib/appwrite/models/oauth2_device_authorization.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "device_code" => "", "user_code" => "", "verification_uri" => "", "verification_uri_complete" => "", "expires_in" => 0, "interval" => 0 }.merge(map) Oauth2DeviceAuthorization.new( device_code: map["device_code"], user_code: map["user_code"], diff --git a/lib/appwrite/models/oauth2_grant.rb b/lib/appwrite/models/oauth2_grant.rb index df5192bf..d94b15c5 100644 --- a/lib/appwrite/models/oauth2_grant.rb +++ b/lib/appwrite/models/oauth2_grant.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "appId" => "", "scopes" => [], "resources" => [], "authorizationDetails" => "[]", "prompt" => "", "redirectUri" => "", "authTime" => 0, "expire" => "" }.merge(map) Oauth2Grant.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/oauth2_introspection.rb b/lib/appwrite/models/oauth2_introspection.rb index ac104dc4..a5f3166a 100644 --- a/lib/appwrite/models/oauth2_introspection.rb +++ b/lib/appwrite/models/oauth2_introspection.rb @@ -18,17 +18,17 @@ class Oauth2Introspection def initialize( active:, - token_use:, - token_type:, - scope:, - client_id:, - sub:, - aud:, - iss:, - exp:, - iat:, - jti:, - authorization_details: + token_use: nil, + token_type: nil, + scope: nil, + client_id: nil, + sub: nil, + aud: nil, + iss: nil, + exp: nil, + iat: nil, + jti: nil, + authorization_details: nil ) @active = active @token_use = token_use diff --git a/lib/appwrite/models/oauth2_organization.rb b/lib/appwrite/models/oauth2_organization.rb index b69fd0cb..70916f0e 100644 --- a/lib/appwrite/models/oauth2_organization.rb +++ b/lib/appwrite/models/oauth2_organization.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "" }.merge(map) Oauth2Organization.new( id: map["$id"] ) diff --git a/lib/appwrite/models/oauth2_organization_list.rb b/lib/appwrite/models/oauth2_organization_list.rb index 7921605a..1988d853 100644 --- a/lib/appwrite/models/oauth2_organization_list.rb +++ b/lib/appwrite/models/oauth2_organization_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "organizations" => [] }.merge(map) Oauth2OrganizationList.new( total: map["total"], organizations: map["organizations"].map { |it| Oauth2Organization.from(map: it) } diff --git a/lib/appwrite/models/oauth2_par.rb b/lib/appwrite/models/oauth2_par.rb index 18198dc6..17b3ee44 100644 --- a/lib/appwrite/models/oauth2_par.rb +++ b/lib/appwrite/models/oauth2_par.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "request_uri" => "", "expires_in" => 0 }.merge(map) Oauth2PAR.new( request_uri: map["request_uri"], expires_in: map["expires_in"] diff --git a/lib/appwrite/models/oauth2_project.rb b/lib/appwrite/models/oauth2_project.rb index 01b2531c..437421b6 100644 --- a/lib/appwrite/models/oauth2_project.rb +++ b/lib/appwrite/models/oauth2_project.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "region" => "", "endpoint" => "" }.merge(map) Oauth2Project.new( id: map["$id"], region: map["region"], diff --git a/lib/appwrite/models/oauth2_project_list.rb b/lib/appwrite/models/oauth2_project_list.rb index a98a6769..d6338e3c 100644 --- a/lib/appwrite/models/oauth2_project_list.rb +++ b/lib/appwrite/models/oauth2_project_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "projects" => [] }.merge(map) Oauth2ProjectList.new( total: map["total"], projects: map["projects"].map { |it| Oauth2Project.from(map: it) } diff --git a/lib/appwrite/models/oauth2_reject.rb b/lib/appwrite/models/oauth2_reject.rb index 614546e0..29325140 100644 --- a/lib/appwrite/models/oauth2_reject.rb +++ b/lib/appwrite/models/oauth2_reject.rb @@ -12,6 +12,7 @@ def initialize( end def self.from(map:) + map = { "redirectUrl" => "" }.merge(map) Oauth2Reject.new( redirect_url: map["redirectUrl"] ) diff --git a/lib/appwrite/models/oauth2_token.rb b/lib/appwrite/models/oauth2_token.rb index 59ffd23f..99b5280d 100644 --- a/lib/appwrite/models/oauth2_token.rb +++ b/lib/appwrite/models/oauth2_token.rb @@ -17,8 +17,8 @@ def initialize( expires_in:, refresh_token:, scope:, - authorization_details:, - id_token: + authorization_details: nil, + id_token: nil ) @access_token = access_token @token_type = token_type @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "access_token" => "", "token_type" => "Bearer", "expires_in" => 0, "refresh_token" => "", "scope" => "" }.merge(map) Oauth2Token.new( access_token: map["access_token"], token_type: map["token_type"], diff --git a/lib/appwrite/models/organization.rb b/lib/appwrite/models/organization.rb index aa53b68a..e4586e85 100644 --- a/lib/appwrite/models/organization.rb +++ b/lib/appwrite/models/organization.rb @@ -46,32 +46,32 @@ def initialize( name:, total:, prefs:, - billing_budget:, + billing_budget: nil, budget_alerts:, billing_plan:, billing_plan_id:, billing_plan_details:, billing_email:, - billing_start_date:, - billing_current_invoice_date:, - billing_next_invoice_date:, - billing_trial_start_date:, - billing_trial_days:, - billing_aggregation_id:, - billing_invoice_id:, - payment_method_id:, - billing_address_id:, - backup_payment_method_id:, + billing_start_date: nil, + billing_current_invoice_date: nil, + billing_next_invoice_date: nil, + billing_trial_start_date: nil, + billing_trial_days: nil, + billing_aggregation_id: nil, + billing_invoice_id: nil, + payment_method_id: nil, + billing_address_id: nil, + backup_payment_method_id: nil, status:, - remarks:, - agreement_baa:, - program_manager_name:, - program_manager_calendar:, - program_discord_channel_name:, - program_discord_channel_url:, - billing_limits:, - billing_plan_downgrade:, - billing_tax_id:, + remarks: nil, + agreement_baa: nil, + program_manager_name: nil, + program_manager_calendar: nil, + program_discord_channel_name: nil, + program_discord_channel_url: nil, + billing_limits: nil, + billing_plan_downgrade: nil, + billing_tax_id: nil, marked_for_deletion:, platform:, projects: @@ -114,6 +114,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "total" => 0, "budgetAlerts" => [75], "billingPlan" => "tier-0", "billingPlanId" => "tier-0", "billingEmail" => "", "status" => "draft", "markedForDeletion" => false, "platform" => "appwrite", "projects" => [] }.merge(map) Organization.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/passkey.rb b/lib/appwrite/models/passkey.rb index 5098b87b..8cea8129 100644 --- a/lib/appwrite/models/passkey.rb +++ b/lib/appwrite/models/passkey.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "accessedAt" => "" }.merge(map) Passkey.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/passkey_challenge.rb b/lib/appwrite/models/passkey_challenge.rb index b9751184..22f1774c 100644 --- a/lib/appwrite/models/passkey_challenge.rb +++ b/lib/appwrite/models/passkey_challenge.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "passkeyId" => "", "expire" => "", "publicKey" => {} }.merge(map) PasskeyChallenge.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/passkey_list.rb b/lib/appwrite/models/passkey_list.rb index 86a515b7..dffca579 100644 --- a/lib/appwrite/models/passkey_list.rb +++ b/lib/appwrite/models/passkey_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "passkeys" => [] }.merge(map) PasskeyList.new( total: map["total"], passkeys: map["passkeys"].map { |it| Passkey.from(map: it) } diff --git a/lib/appwrite/models/phone.rb b/lib/appwrite/models/phone.rb index 769ea1be..c4d5137c 100644 --- a/lib/appwrite/models/phone.rb +++ b/lib/appwrite/models/phone.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "code" => "", "countryCode" => "", "countryName" => "" }.merge(map) Phone.new( code: map["code"], country_code: map["countryCode"], diff --git a/lib/appwrite/models/phone_list.rb b/lib/appwrite/models/phone_list.rb index d6ad3e14..fea0fea8 100644 --- a/lib/appwrite/models/phone_list.rb +++ b/lib/appwrite/models/phone_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "phones" => [] }.merge(map) PhoneList.new( total: map["total"], phones: map["phones"].map { |it| Phone.from(map: it) } diff --git a/lib/appwrite/models/platform_android.rb b/lib/appwrite/models/platform_android.rb index da5ba79b..3559270e 100644 --- a/lib/appwrite/models/platform_android.rb +++ b/lib/appwrite/models/platform_android.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "applicationId" => "", "fingerprints" => [] }.merge(map) PlatformAndroid.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_apple.rb b/lib/appwrite/models/platform_apple.rb index 06f7aeea..fa95f584 100644 --- a/lib/appwrite/models/platform_apple.rb +++ b/lib/appwrite/models/platform_apple.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "bundleIdentifier" => "" }.merge(map) PlatformApple.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_linux.rb b/lib/appwrite/models/platform_linux.rb index 1442fd5e..a35bc2ca 100644 --- a/lib/appwrite/models/platform_linux.rb +++ b/lib/appwrite/models/platform_linux.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "packageName" => "" }.merge(map) PlatformLinux.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_list.rb b/lib/appwrite/models/platform_list.rb index a51bb20e..c18d4b33 100644 --- a/lib/appwrite/models/platform_list.rb +++ b/lib/appwrite/models/platform_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "platforms" => [] }.merge(map) PlatformList.new( total: map["total"], platforms: map["platforms"] diff --git a/lib/appwrite/models/platform_web.rb b/lib/appwrite/models/platform_web.rb index 8e84519d..a3925665 100644 --- a/lib/appwrite/models/platform_web.rb +++ b/lib/appwrite/models/platform_web.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "hostname" => "" }.merge(map) PlatformWeb.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/platform_windows.rb b/lib/appwrite/models/platform_windows.rb index 560f44d4..07d1e9d5 100644 --- a/lib/appwrite/models/platform_windows.rb +++ b/lib/appwrite/models/platform_windows.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "packageIdentifierName" => "" }.merge(map) PlatformWindows.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/policy_deny_aliased_email.rb b/lib/appwrite/models/policy_deny_aliased_email.rb index f7b755ae..1a05ce5d 100644 --- a/lib/appwrite/models/policy_deny_aliased_email.rb +++ b/lib/appwrite/models/policy_deny_aliased_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyAliasedEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_deny_corporate_email.rb b/lib/appwrite/models/policy_deny_corporate_email.rb index 4bdf38ae..3680ef40 100644 --- a/lib/appwrite/models/policy_deny_corporate_email.rb +++ b/lib/appwrite/models/policy_deny_corporate_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyCorporateEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_deny_disposable_email.rb b/lib/appwrite/models/policy_deny_disposable_email.rb index 23393bea..f3073750 100644 --- a/lib/appwrite/models/policy_deny_disposable_email.rb +++ b/lib/appwrite/models/policy_deny_disposable_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyDisposableEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_deny_free_email.rb b/lib/appwrite/models/policy_deny_free_email.rb index 766573bb..75bca6f0 100644 --- a/lib/appwrite/models/policy_deny_free_email.rb +++ b/lib/appwrite/models/policy_deny_free_email.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyDenyFreeEmail.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_list.rb b/lib/appwrite/models/policy_list.rb index 077c62f5..7c5be92c 100644 --- a/lib/appwrite/models/policy_list.rb +++ b/lib/appwrite/models/policy_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "policies" => [] }.merge(map) PolicyList.new( total: map["total"], policies: map["policies"] diff --git a/lib/appwrite/models/policy_membership_privacy.rb b/lib/appwrite/models/policy_membership_privacy.rb index 9fa040f1..2a1a56a4 100644 --- a/lib/appwrite/models/policy_membership_privacy.rb +++ b/lib/appwrite/models/policy_membership_privacy.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "userId" => false, "userEmail" => false, "userPhone" => false, "userName" => false, "userMFA" => false, "userAccessedAt" => false }.merge(map) PolicyMembershipPrivacy.new( id: map["$id"], user_id: map["userId"], diff --git a/lib/appwrite/models/policy_mfa_factors.rb b/lib/appwrite/models/policy_mfa_factors.rb index e49890a8..601ef66d 100644 --- a/lib/appwrite/models/policy_mfa_factors.rb +++ b/lib/appwrite/models/policy_mfa_factors.rb @@ -24,6 +24,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "totp" => true, "email" => true, "phone" => true, "custom" => false }.merge(map) PolicyMfaFactors.new( id: map["$id"], totp: map["totp"], diff --git a/lib/appwrite/models/policy_passkey.rb b/lib/appwrite/models/policy_passkey.rb index f9cb6701..62bced03 100644 --- a/lib/appwrite/models/policy_passkey.rb +++ b/lib/appwrite/models/policy_passkey.rb @@ -18,6 +18,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "rpId" => "", "origins" => [] }.merge(map) PolicyPasskey.new( id: map["$id"], rp_id: map["rpId"], diff --git a/lib/appwrite/models/policy_password_dictionary.rb b/lib/appwrite/models/policy_password_dictionary.rb index 38423bc4..b72d0caa 100644 --- a/lib/appwrite/models/policy_password_dictionary.rb +++ b/lib/appwrite/models/policy_password_dictionary.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyPasswordDictionary.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_password_history.rb b/lib/appwrite/models/policy_password_history.rb index e2d4b842..f5253d15 100644 --- a/lib/appwrite/models/policy_password_history.rb +++ b/lib/appwrite/models/policy_password_history.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "total" => 0 }.merge(map) PolicyPasswordHistory.new( id: map["$id"], total: map["total"] diff --git a/lib/appwrite/models/policy_password_personal_data.rb b/lib/appwrite/models/policy_password_personal_data.rb index 7e2c290e..2be97bd8 100644 --- a/lib/appwrite/models/policy_password_personal_data.rb +++ b/lib/appwrite/models/policy_password_personal_data.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicyPasswordPersonalData.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_password_strength.rb b/lib/appwrite/models/policy_password_strength.rb index c2bf28fb..1240c6a0 100644 --- a/lib/appwrite/models/policy_password_strength.rb +++ b/lib/appwrite/models/policy_password_strength.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "min" => 8, "uppercase" => false, "lowercase" => false, "number" => false, "symbols" => false }.merge(map) PolicyPasswordStrength.new( id: map["$id"], min: map["min"], diff --git a/lib/appwrite/models/policy_session_alert.rb b/lib/appwrite/models/policy_session_alert.rb index 74ee3fa2..7ef6a816 100644 --- a/lib/appwrite/models/policy_session_alert.rb +++ b/lib/appwrite/models/policy_session_alert.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => false }.merge(map) PolicySessionAlert.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_session_duration.rb b/lib/appwrite/models/policy_session_duration.rb index f23f26e9..2928b255 100644 --- a/lib/appwrite/models/policy_session_duration.rb +++ b/lib/appwrite/models/policy_session_duration.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "duration" => 31536000 }.merge(map) PolicySessionDuration.new( id: map["$id"], duration: map["duration"] diff --git a/lib/appwrite/models/policy_session_invalidation.rb b/lib/appwrite/models/policy_session_invalidation.rb index 4c7b0a2e..6ec72c3b 100644 --- a/lib/appwrite/models/policy_session_invalidation.rb +++ b/lib/appwrite/models/policy_session_invalidation.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "enabled" => true }.merge(map) PolicySessionInvalidation.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/policy_session_limit.rb b/lib/appwrite/models/policy_session_limit.rb index 2c3783d8..193d81b5 100644 --- a/lib/appwrite/models/policy_session_limit.rb +++ b/lib/appwrite/models/policy_session_limit.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "total" => 0 }.merge(map) PolicySessionLimit.new( id: map["$id"], total: map["total"] diff --git a/lib/appwrite/models/policy_user_limit.rb b/lib/appwrite/models/policy_user_limit.rb index b5554c19..1275753d 100644 --- a/lib/appwrite/models/policy_user_limit.rb +++ b/lib/appwrite/models/policy_user_limit.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "total" => 0 }.merge(map) PolicyUserLimit.new( id: map["$id"], total: map["total"] diff --git a/lib/appwrite/models/postgres_extension.rb b/lib/appwrite/models/postgres_extension.rb index 6ae09339..e1c5f081 100644 --- a/lib/appwrite/models/postgres_extension.rb +++ b/lib/appwrite/models/postgres_extension.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "key" => "", "name" => "", "description" => "", "category" => "" }.merge(map) PostgresExtension.new( key: map["key"], name: map["name"], diff --git a/lib/appwrite/models/presence.rb b/lib/appwrite/models/presence.rb index dabfb838..d32347b4 100644 --- a/lib/appwrite/models/presence.rb +++ b/lib/appwrite/models/presence.rb @@ -19,10 +19,10 @@ def initialize( updated_at:, permissions:, user_id:, - status:, + status: nil, source:, - expires_at:, - metadata: + expires_at: nil, + metadata: nil ) @id = id @created_at = created_at @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "userId" => "", "source" => "" }.merge(map) Presence.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/presence_list.rb b/lib/appwrite/models/presence_list.rb index 01fa5bcb..b43ba834 100644 --- a/lib/appwrite/models/presence_list.rb +++ b/lib/appwrite/models/presence_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "presences" => [] }.merge(map) PresenceList.new( total: map["total"], presences: map["presences"].map { |it| Presence.from(map: it) } diff --git a/lib/appwrite/models/program.rb b/lib/appwrite/models/program.rb index db9215e1..7705670c 100644 --- a/lib/appwrite/models/program.rb +++ b/lib/appwrite/models/program.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "title" => "", "description" => "", "tag" => "", "icon" => "", "url" => "", "active" => true, "external" => true, "billingPlanId" => "" }.merge(map) Program.new( id: map["$id"], title: map["title"], diff --git a/lib/appwrite/models/project.rb b/lib/appwrite/models/project.rb index b03fcbc6..9d8916c7 100644 --- a/lib/appwrite/models/project.rb +++ b/lib/appwrite/models/project.rb @@ -9,7 +9,6 @@ class Project attr_reader :name attr_reader :team_id attr_reader :region - attr_reader :dev_keys attr_reader :smtp_enabled attr_reader :smtp_sender_name attr_reader :smtp_sender_email @@ -60,7 +59,6 @@ def initialize( name:, team_id:, region:, - dev_keys:, smtp_enabled:, smtp_sender_name:, smtp_sender_email:, @@ -81,28 +79,28 @@ def initialize( protocols:, blocks:, console_accessed_at:, - waf_enabled:, - parent_id:, - billing_limits:, - first_accessed_at:, - mcp_accessed_at:, - o_auth2_server_enabled:, - o_auth2_server_authorization_url:, - o_auth2_server_scopes:, - o_auth2_server_default_scopes:, - o_auth2_server_installation_scopes:, - o_auth2_server_authorization_details_types:, - o_auth2_server_access_token_duration:, - 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:, - o_auth2_server_user_code_format:, - o_auth2_server_device_code_duration:, - o_auth2_server_discovery_url: + waf_enabled: false, + parent_id: nil, + billing_limits: nil, + first_accessed_at: nil, + mcp_accessed_at: nil, + o_auth2_server_enabled: false, + o_auth2_server_authorization_url: nil, + o_auth2_server_scopes: [], + o_auth2_server_default_scopes: [], + o_auth2_server_installation_scopes: [], + o_auth2_server_authorization_details_types: [], + o_auth2_server_access_token_duration: 0, + o_auth2_server_refresh_token_duration: 0, + o_auth2_server_public_access_token_duration: 0, + o_auth2_server_public_refresh_token_duration: 0, + o_auth2_server_installation_access_token_duration: 0, + o_auth2_server_confidential_pkce: false, + o_auth2_server_verification_url: nil, + o_auth2_server_user_code_length: 8, + o_auth2_server_user_code_format: "alphanumeric", + o_auth2_server_device_code_duration: 600, + o_auth2_server_discovery_url: nil ) @id = id @created_at = created_at @@ -110,7 +108,6 @@ def initialize( @name = name @team_id = team_id @region = region - @dev_keys = dev_keys @smtp_enabled = smtp_enabled @smtp_sender_name = smtp_sender_name @smtp_sender_email = smtp_sender_email @@ -156,6 +153,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "teamId" => "", "region" => "fra", "smtpEnabled" => false, "smtpSenderName" => "", "smtpSenderEmail" => "", "smtpReplyToName" => "", "smtpReplyToEmail" => "", "smtpHost" => "", "smtpPort" => 0, "smtpUsername" => "", "smtpPassword" => "", "smtpSecure" => "", "pingCount" => 0, "pingedAt" => "", "labels" => [], "status" => "active", "onboarding" => {}, "authMethods" => [], "services" => [], "protocols" => [], "blocks" => [], "consoleAccessedAt" => "" }.merge(map) Project.new( id: map["$id"], created_at: map["$createdAt"], @@ -163,7 +161,6 @@ def self.from(map:) name: map["name"], team_id: map["teamId"], region: map["region"], - dev_keys: map["devKeys"].map { |it| DevKey.from(map: it) }, smtp_enabled: map["smtpEnabled"], smtp_sender_name: map["smtpSenderName"], smtp_sender_email: map["smtpSenderEmail"], @@ -217,7 +214,6 @@ def to_map "name": @name, "teamId": @team_id, "region": @region, - "devKeys": @dev_keys.map { |it| it.to_map }, "smtpEnabled": @smtp_enabled, "smtpSenderName": @smtp_sender_name, "smtpSenderEmail": @smtp_sender_email, diff --git a/lib/appwrite/models/project_auth_method.rb b/lib/appwrite/models/project_auth_method.rb index 98c67156..23162ba9 100644 --- a/lib/appwrite/models/project_auth_method.rb +++ b/lib/appwrite/models/project_auth_method.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => true }.merge(map) ProjectAuthMethod.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/project_list.rb b/lib/appwrite/models/project_list.rb index 552309a5..f2fd282a 100644 --- a/lib/appwrite/models/project_list.rb +++ b/lib/appwrite/models/project_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "projects" => [] }.merge(map) ProjectList.new( total: map["total"], projects: map["projects"].map { |it| Project.from(map: it) } diff --git a/lib/appwrite/models/project_protocol.rb b/lib/appwrite/models/project_protocol.rb index 58448214..a3071c87 100644 --- a/lib/appwrite/models/project_protocol.rb +++ b/lib/appwrite/models/project_protocol.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => true }.merge(map) ProjectProtocol.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/project_service.rb b/lib/appwrite/models/project_service.rb index 128c31b0..a4ea7343 100644 --- a/lib/appwrite/models/project_service.rb +++ b/lib/appwrite/models/project_service.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "enabled" => true }.merge(map) ProjectService.new( id: map["$id"], enabled: map["enabled"] diff --git a/lib/appwrite/models/provider.rb b/lib/appwrite/models/provider.rb index 80d6c956..90a53b7c 100644 --- a/lib/appwrite/models/provider.rb +++ b/lib/appwrite/models/provider.rb @@ -22,7 +22,7 @@ def initialize( enabled:, type:, credentials:, - options: + options: {} ) @id = id @created_at = created_at @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "provider" => "", "enabled" => true, "type" => "", "credentials" => {} }.merge(map) Provider.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/provider_list.rb b/lib/appwrite/models/provider_list.rb index 32f7da98..46909a15 100644 --- a/lib/appwrite/models/provider_list.rb +++ b/lib/appwrite/models/provider_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "providers" => [] }.merge(map) ProviderList.new( total: map["total"], providers: map["providers"].map { |it| Provider.from(map: it) } diff --git a/lib/appwrite/models/proxy_invalidation.rb b/lib/appwrite/models/proxy_invalidation.rb index 584669ac..872f90e6 100644 --- a/lib/appwrite/models/proxy_invalidation.rb +++ b/lib/appwrite/models/proxy_invalidation.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "domain" => "", "type" => "", "reference" => "", "status" => "" }.merge(map) ProxyInvalidation.new( domain: map["domain"], type: map["type"], diff --git a/lib/appwrite/models/proxy_rule.rb b/lib/appwrite/models/proxy_rule.rb index e37a6e6d..e46b6dc8 100644 --- a/lib/appwrite/models/proxy_rule.rb +++ b/lib/appwrite/models/proxy_rule.rb @@ -18,6 +18,7 @@ class ProxyRule attr_reader :status attr_reader :logs attr_reader :renew_at + attr_reader :protocol def initialize( id:, @@ -29,12 +30,13 @@ def initialize( redirect_url:, redirect_status_code:, deployment_id:, - deployment_resource_type:, + deployment_resource_type: nil, deployment_resource_id:, deployment_vcs_provider_branch:, status:, logs:, - renew_at: + renew_at:, + protocol: ) @id = id @created_at = created_at @@ -51,9 +53,11 @@ def initialize( @status = validate_status(status) @logs = logs @renew_at = renew_at + @protocol = validate_protocol(protocol) end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "domain" => "", "type" => "", "trigger" => "", "redirectUrl" => "", "redirectStatusCode" => 301, "deploymentId" => "", "deploymentResourceId" => "", "deploymentVcsProviderBranch" => "", "status" => "unverified", "logs" => "", "protocol" => "http" }.merge(map) ProxyRule.new( id: map["$id"], created_at: map["$createdAt"], @@ -69,7 +73,8 @@ def self.from(map:) deployment_vcs_provider_branch: map["deploymentVcsProviderBranch"], status: map["status"], logs: map["logs"], - renew_at: map["renewAt"] + renew_at: map["renewAt"], + protocol: map["protocol"] ) end @@ -89,7 +94,8 @@ def to_map "deploymentVcsProviderBranch": @deployment_vcs_provider_branch, "status": @status, "logs": @logs, - "renewAt": @renew_at + "renewAt": @renew_at, + "protocol": @protocol } end @@ -122,6 +128,19 @@ def validate_status(status) status end + + def validate_protocol(protocol) + valid_protocol = [ + Appwrite::Enums::ProxyRuleProtocol::HTTP, + Appwrite::Enums::ProxyRuleProtocol::SMTP, + ] + + unless valid_protocol.include?(protocol) + raise ArgumentError, "Invalid " + protocol + ". Must be one of: " + valid_protocol.join(', ') + end + + protocol + end end end end diff --git a/lib/appwrite/models/proxy_rule_list.rb b/lib/appwrite/models/proxy_rule_list.rb index 24f99239..3f324ae8 100644 --- a/lib/appwrite/models/proxy_rule_list.rb +++ b/lib/appwrite/models/proxy_rule_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "rules" => [] }.merge(map) ProxyRuleList.new( total: map["total"], rules: map["rules"].map { |it| ProxyRule.from(map: it) } diff --git a/lib/appwrite/models/report.rb b/lib/appwrite/models/report.rb index b3912319..8fed5800 100644 --- a/lib/appwrite/models/report.rb +++ b/lib/appwrite/models/report.rb @@ -28,7 +28,7 @@ def initialize( target:, categories:, insights:, - analyzed_at: + analyzed_at: nil ) @id = id @created_at = created_at @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "appId" => "", "type" => "", "title" => "", "summary" => "", "targetType" => "", "target" => "", "categories" => [], "insights" => [] }.merge(map) Report.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/report_list.rb b/lib/appwrite/models/report_list.rb index 8cdd69a0..40a7cee2 100644 --- a/lib/appwrite/models/report_list.rb +++ b/lib/appwrite/models/report_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "reports" => [] }.merge(map) ReportList.new( total: map["total"], reports: map["reports"].map { |it| Report.from(map: it) } diff --git a/lib/appwrite/models/resource_token.rb b/lib/appwrite/models/resource_token.rb index 61c2b49e..a5d39ace 100644 --- a/lib/appwrite/models/resource_token.rb +++ b/lib/appwrite/models/resource_token.rb @@ -30,6 +30,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "resourceId" => "", "resourceType" => "", "expire" => "", "secret" => "", "accessedAt" => "" }.merge(map) ResourceToken.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/resource_token_list.rb b/lib/appwrite/models/resource_token_list.rb index 928b7825..a07536c6 100644 --- a/lib/appwrite/models/resource_token_list.rb +++ b/lib/appwrite/models/resource_token_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "tokens" => [] }.merge(map) ResourceTokenList.new( total: map["total"], tokens: map["tokens"].map { |it| ResourceToken.from(map: it) } diff --git a/lib/appwrite/models/row.rb b/lib/appwrite/models/row.rb index c19c0445..2407b2ca 100644 --- a/lib/appwrite/models/row.rb +++ b/lib/appwrite/models/row.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$sequence" => "", "$tableId" => "", "$databaseId" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [] }.merge(map) Row.new( id: map["$id"], sequence: map["$sequence"], diff --git a/lib/appwrite/models/row_list.rb b/lib/appwrite/models/row_list.rb index debd9e50..55bcab78 100644 --- a/lib/appwrite/models/row_list.rb +++ b/lib/appwrite/models/row_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "rows" => [] }.merge(map) RowList.new( total: map["total"], rows: map["rows"].map { |it| Row.from(map: it) } diff --git a/lib/appwrite/models/runtime.rb b/lib/appwrite/models/runtime.rb index 4a09aa27..840663d4 100644 --- a/lib/appwrite/models/runtime.rb +++ b/lib/appwrite/models/runtime.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "key" => "", "name" => "", "version" => "", "base" => "", "image" => "", "logo" => "", "supports" => [] }.merge(map) Runtime.new( id: map["$id"], key: map["key"], diff --git a/lib/appwrite/models/runtime_list.rb b/lib/appwrite/models/runtime_list.rb index 5b69b4a6..018a5bf6 100644 --- a/lib/appwrite/models/runtime_list.rb +++ b/lib/appwrite/models/runtime_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "runtimes" => [] }.merge(map) RuntimeList.new( total: map["total"], runtimes: map["runtimes"].map { |it| Runtime.from(map: it) } diff --git a/lib/appwrite/models/session.rb b/lib/appwrite/models/session.rb index 762ee427..0777f369 100644 --- a/lib/appwrite/models/session.rb +++ b/lib/appwrite/models/session.rb @@ -96,6 +96,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "expire" => "", "provider" => "", "providerUid" => "", "providerAccessToken" => "", "providerAccessTokenExpiry" => "", "providerRefreshToken" => "", "ip" => "", "osCode" => "", "osName" => "", "osVersion" => "", "clientType" => "", "clientCode" => "", "clientName" => "", "clientVersion" => "", "clientEngine" => "", "clientEngineVersion" => "", "deviceName" => "", "deviceBrand" => "", "deviceModel" => "", "countryCode" => "", "countryName" => "", "current" => false, "factors" => [], "secret" => "", "mfaUpdatedAt" => "" }.merge(map) Session.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/session_list.rb b/lib/appwrite/models/session_list.rb index 320cefec..b55a7b94 100644 --- a/lib/appwrite/models/session_list.rb +++ b/lib/appwrite/models/session_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "sessions" => [] }.merge(map) SessionList.new( total: map["total"], sessions: map["sessions"].map { |it| Session.from(map: it) } diff --git a/lib/appwrite/models/site.rb b/lib/appwrite/models/site.rb index 94e80f00..60300827 100644 --- a/lib/appwrite/models/site.rb +++ b/lib/appwrite/models/site.rb @@ -114,6 +114,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "enabled" => true, "live" => true, "logging" => true, "framework" => "", "deploymentRetention" => 0, "deploymentId" => "", "deploymentCreatedAt" => "", "deploymentScreenshotLight" => "", "deploymentScreenshotDark" => "", "latestDeploymentId" => "", "latestDeploymentCreatedAt" => "", "latestDeploymentStatus" => "", "scopes" => [], "vars" => [], "timeout" => 15, "installCommand" => "", "buildCommand" => "", "startCommand" => "", "outputDirectory" => "", "installationId" => "", "providerRepositoryId" => "", "providerBranch" => "", "providerRootDirectory" => "", "providerSilentMode" => false, "providerBranches" => [], "providerPaths" => [], "buildSpecification" => "s-1vcpu-512mb", "runtimeSpecification" => "s-1vcpu-512mb", "buildRuntime" => "" }.merge(map) Site.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/site_list.rb b/lib/appwrite/models/site_list.rb index 51fb319d..f9537cc7 100644 --- a/lib/appwrite/models/site_list.rb +++ b/lib/appwrite/models/site_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "sites" => [] }.merge(map) SiteList.new( total: map["total"], sites: map["sites"].map { |it| Site.from(map: it) } diff --git a/lib/appwrite/models/specification.rb b/lib/appwrite/models/specification.rb index e9ff5467..b8606f25 100644 --- a/lib/appwrite/models/specification.rb +++ b/lib/appwrite/models/specification.rb @@ -21,6 +21,7 @@ def initialize( end def self.from(map:) + map = { "memory" => 0, "cpus" => 0, "enabled" => false, "slug" => "" }.merge(map) Specification.new( memory: map["memory"], cpus: map["cpus"], diff --git a/lib/appwrite/models/specification_list.rb b/lib/appwrite/models/specification_list.rb index 8212053d..f79e4e31 100644 --- a/lib/appwrite/models/specification_list.rb +++ b/lib/appwrite/models/specification_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "specifications" => [] }.merge(map) SpecificationList.new( total: map["total"], specifications: map["specifications"].map { |it| Specification.from(map: it) } diff --git a/lib/appwrite/models/subscriber.rb b/lib/appwrite/models/subscriber.rb index 318baaab..b2e07da3 100644 --- a/lib/appwrite/models/subscriber.rb +++ b/lib/appwrite/models/subscriber.rb @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "targetId" => "", "userId" => "", "userName" => "", "topicId" => "", "providerType" => "" }.merge(map) Subscriber.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/subscriber_list.rb b/lib/appwrite/models/subscriber_list.rb index 01373385..904bf7d0 100644 --- a/lib/appwrite/models/subscriber_list.rb +++ b/lib/appwrite/models/subscriber_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "subscribers" => [] }.merge(map) SubscriberList.new( total: map["total"], subscribers: map["subscribers"].map { |it| Subscriber.from(map: it) } diff --git a/lib/appwrite/models/table.rb b/lib/appwrite/models/table.rb index 2a7e4649..69851a39 100644 --- a/lib/appwrite/models/table.rb +++ b/lib/appwrite/models/table.rb @@ -45,6 +45,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "databaseId" => "", "name" => "", "enabled" => true, "rowSecurity" => false, "columns" => [], "indexes" => [], "bytesMax" => 0, "bytesUsed" => 0 }.merge(map) Table.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/table_list.rb b/lib/appwrite/models/table_list.rb index 034d7fb3..98d96311 100644 --- a/lib/appwrite/models/table_list.rb +++ b/lib/appwrite/models/table_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "tables" => [] }.merge(map) TableList.new( total: map["total"], tables: map["tables"].map { |it| Table.from(map: it) } diff --git a/lib/appwrite/models/target.rb b/lib/appwrite/models/target.rb index 56e90755..29d79129 100644 --- a/lib/appwrite/models/target.rb +++ b/lib/appwrite/models/target.rb @@ -19,7 +19,7 @@ def initialize( updated_at:, name:, user_id:, - provider_id:, + provider_id: nil, provider_type:, identifier:, expired: @@ -36,6 +36,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "userId" => "", "providerType" => "", "identifier" => "", "expired" => false }.merge(map) Target.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/target_list.rb b/lib/appwrite/models/target_list.rb index 9ccd7705..1c7fe0e8 100644 --- a/lib/appwrite/models/target_list.rb +++ b/lib/appwrite/models/target_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "targets" => [] }.merge(map) TargetList.new( total: map["total"], targets: map["targets"].map { |it| Target.from(map: it) } diff --git a/lib/appwrite/models/team.rb b/lib/appwrite/models/team.rb index d08f183f..06bcaf72 100644 --- a/lib/appwrite/models/team.rb +++ b/lib/appwrite/models/team.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "total" => 0 }.merge(map) Team.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/team_list.rb b/lib/appwrite/models/team_list.rb index e02efc9c..01300672 100644 --- a/lib/appwrite/models/team_list.rb +++ b/lib/appwrite/models/team_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "teams" => [] }.merge(map) TeamList.new( total: map["total"], teams: map["teams"].map { |it| Team.from(map: it) } diff --git a/lib/appwrite/models/token.rb b/lib/appwrite/models/token.rb index b3f539af..bf6c51a9 100644 --- a/lib/appwrite/models/token.rb +++ b/lib/appwrite/models/token.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "secret" => "", "expire" => "", "phrase" => "" }.merge(map) Token.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/token_secret.rb b/lib/appwrite/models/token_secret.rb index 4744532f..31ef131b 100644 --- a/lib/appwrite/models/token_secret.rb +++ b/lib/appwrite/models/token_secret.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "secret" => "", "expire" => "", "phrase" => "" }.merge(map) TokenSecret.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/topic.rb b/lib/appwrite/models/topic.rb index 247284d8..b029a406 100644 --- a/lib/appwrite/models/topic.rb +++ b/lib/appwrite/models/topic.rb @@ -23,8 +23,8 @@ def initialize( sms_total:, push_total:, subscribe:, - qos:, - expiry: + qos: nil, + expiry: nil ) @id = id @created_at = created_at @@ -39,6 +39,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "emailTotal" => 0, "smsTotal" => 0, "pushTotal" => 0, "subscribe" => ["users"] }.merge(map) Topic.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/topic_list.rb b/lib/appwrite/models/topic_list.rb index e1b8c6d0..9542c588 100644 --- a/lib/appwrite/models/topic_list.rb +++ b/lib/appwrite/models/topic_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "topics" => [] }.merge(map) TopicList.new( total: map["total"], topics: map["topics"].map { |it| Topic.from(map: it) } diff --git a/lib/appwrite/models/transaction.rb b/lib/appwrite/models/transaction.rb index 481c25c9..e35a80fa 100644 --- a/lib/appwrite/models/transaction.rb +++ b/lib/appwrite/models/transaction.rb @@ -27,6 +27,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "status" => "pending", "operations" => 0, "expiresAt" => "" }.merge(map) Transaction.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/transaction_list.rb b/lib/appwrite/models/transaction_list.rb index 17234abd..0db83c65 100644 --- a/lib/appwrite/models/transaction_list.rb +++ b/lib/appwrite/models/transaction_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "transactions" => [] }.merge(map) TransactionList.new( total: map["total"], transactions: map["transactions"].map { |it| Transaction.from(map: it) } diff --git a/lib/appwrite/models/usage_billing_plan.rb b/lib/appwrite/models/usage_billing_plan.rb index be1d81f6..b0f296c6 100644 --- a/lib/appwrite/models/usage_billing_plan.rb +++ b/lib/appwrite/models/usage_billing_plan.rb @@ -16,17 +16,17 @@ class UsageBillingPlan attr_reader :credits def initialize( - bandwidth:, - executions:, - member:, - realtime:, - realtime_messages:, - realtime_bandwidth:, - storage:, - users:, - gb_hours:, - image_transformations:, - credits: + bandwidth: nil, + executions: nil, + member: nil, + realtime: nil, + realtime_messages: nil, + realtime_bandwidth: nil, + storage: nil, + users: nil, + gb_hours: nil, + image_transformations: nil, + credits: nil ) @bandwidth = bandwidth @executions = executions @@ -43,32 +43,32 @@ def initialize( def self.from(map:) UsageBillingPlan.new( - bandwidth: AdditionalResource.from(map: map["bandwidth"]), - executions: AdditionalResource.from(map: map["executions"]), + bandwidth: map["bandwidth"].nil? ? nil : AdditionalResource.from(map: map["bandwidth"]), + executions: map["executions"].nil? ? nil : AdditionalResource.from(map: map["executions"]), member: map["member"].nil? ? nil : AdditionalResource.from(map: map["member"]), - realtime: AdditionalResource.from(map: map["realtime"]), - realtime_messages: AdditionalResource.from(map: map["realtimeMessages"]), + realtime: map["realtime"].nil? ? nil : AdditionalResource.from(map: map["realtime"]), + realtime_messages: map["realtimeMessages"].nil? ? nil : AdditionalResource.from(map: map["realtimeMessages"]), realtime_bandwidth: map["realtimeBandwidth"].nil? ? nil : AdditionalResource.from(map: map["realtimeBandwidth"]), - storage: AdditionalResource.from(map: map["storage"]), - users: AdditionalResource.from(map: map["users"]), - gb_hours: AdditionalResource.from(map: map["GBHours"]), - image_transformations: AdditionalResource.from(map: map["imageTransformations"]), + storage: map["storage"].nil? ? nil : AdditionalResource.from(map: map["storage"]), + users: map["users"].nil? ? nil : AdditionalResource.from(map: map["users"]), + gb_hours: map["GBHours"].nil? ? nil : AdditionalResource.from(map: map["GBHours"]), + image_transformations: map["imageTransformations"].nil? ? nil : AdditionalResource.from(map: map["imageTransformations"]), credits: map["credits"].nil? ? nil : AdditionalResource.from(map: map["credits"]) ) end def to_map { - "bandwidth": @bandwidth.to_map, - "executions": @executions.to_map, + "bandwidth": @bandwidth&.to_map, + "executions": @executions&.to_map, "member": @member&.to_map, - "realtime": @realtime.to_map, - "realtimeMessages": @realtime_messages.to_map, + "realtime": @realtime&.to_map, + "realtimeMessages": @realtime_messages&.to_map, "realtimeBandwidth": @realtime_bandwidth&.to_map, - "storage": @storage.to_map, - "users": @users.to_map, - "GBHours": @gb_hours.to_map, - "imageTransformations": @image_transformations.to_map, + "storage": @storage&.to_map, + "users": @users&.to_map, + "GBHours": @gb_hours&.to_map, + "imageTransformations": @image_transformations&.to_map, "credits": @credits&.to_map } end diff --git a/lib/appwrite/models/user.rb b/lib/appwrite/models/user.rb index 9586ee8c..dc1bae80 100644 --- a/lib/appwrite/models/user.rb +++ b/lib/appwrite/models/user.rb @@ -36,9 +36,9 @@ def initialize( created_at:, updated_at:, name:, - password:, - hash:, - hash_options:, + password: nil, + hash: nil, + hash_options: nil, registration:, status:, labels:, @@ -46,19 +46,19 @@ def initialize( email:, phone:, email_verification:, - email_canonical:, - email_is_free:, - email_is_disposable:, - email_is_corporate:, - email_is_canonical:, - password_pwned:, + email_canonical: nil, + email_is_free: nil, + email_is_disposable: nil, + email_is_corporate: nil, + email_is_canonical: nil, + password_pwned: nil, phone_verification:, mfa:, prefs:, targets:, accessed_at:, - impersonator:, - impersonator_user_id: + impersonator: false, + impersonator_user_id: nil ) @id = id @created_at = created_at @@ -90,6 +90,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "registration" => "", "status" => true, "labels" => [], "passwordUpdate" => "", "email" => "", "phone" => "", "emailVerification" => false, "phoneVerification" => false, "mfa" => false, "targets" => [], "accessedAt" => "" }.merge(map) User.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/user_list.rb b/lib/appwrite/models/user_list.rb index 79c4c6d3..62660196 100644 --- a/lib/appwrite/models/user_list.rb +++ b/lib/appwrite/models/user_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "users" => [] }.merge(map) UserList.new( total: map["total"], users: map["users"].map { |it| User.from(map: it) } diff --git a/lib/appwrite/models/variable.rb b/lib/appwrite/models/variable.rb index 1c14a73d..d5722127 100644 --- a/lib/appwrite/models/variable.rb +++ b/lib/appwrite/models/variable.rb @@ -33,6 +33,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "key" => "", "value" => "", "secret" => false, "resourceType" => "", "resourceId" => "" }.merge(map) Variable.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/variable_list.rb b/lib/appwrite/models/variable_list.rb index 6c36b9d1..bfe9230f 100644 --- a/lib/appwrite/models/variable_list.rb +++ b/lib/appwrite/models/variable_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "variables" => [] }.merge(map) VariableList.new( total: map["total"], variables: map["variables"].map { |it| Variable.from(map: it) } diff --git a/lib/appwrite/models/vectorsdb_collection.rb b/lib/appwrite/models/vectorsdb_collection.rb index fc878665..0f3842c3 100644 --- a/lib/appwrite/models/vectorsdb_collection.rb +++ b/lib/appwrite/models/vectorsdb_collection.rb @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "databaseId" => "", "name" => "", "enabled" => true, "documentSecurity" => false, "attributes" => [], "indexes" => [], "bytesMax" => 0, "bytesUsed" => 0, "dimension" => 0 }.merge(map) VectorsdbCollection.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/vectorsdb_collection_list.rb b/lib/appwrite/models/vectorsdb_collection_list.rb index e933696b..e38a9a4d 100644 --- a/lib/appwrite/models/vectorsdb_collection_list.rb +++ b/lib/appwrite/models/vectorsdb_collection_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "collections" => [] }.merge(map) VectorsdbCollectionList.new( total: map["total"], collections: map["collections"].map { |it| VectorsdbCollection.from(map: it) } diff --git a/lib/appwrite/models/webhook.rb b/lib/appwrite/models/webhook.rb index 5e418078..333fc55b 100644 --- a/lib/appwrite/models/webhook.rb +++ b/lib/appwrite/models/webhook.rb @@ -48,6 +48,7 @@ def initialize( end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "url" => "", "events" => [], "tls" => true, "authUsername" => "", "authPassword" => "", "secret" => "", "enabled" => true, "logs" => "", "attempts" => 0 }.merge(map) Webhook.new( id: map["$id"], created_at: map["$createdAt"], diff --git a/lib/appwrite/models/webhook_list.rb b/lib/appwrite/models/webhook_list.rb index 1df070b9..ee1af6f5 100644 --- a/lib/appwrite/models/webhook_list.rb +++ b/lib/appwrite/models/webhook_list.rb @@ -15,6 +15,7 @@ def initialize( end def self.from(map:) + map = { "total" => 0, "webhooks" => [] }.merge(map) WebhookList.new( total: map["total"], webhooks: map["webhooks"].map { |it| Webhook.from(map: it) } diff --git a/lib/appwrite/query.rb b/lib/appwrite/query.rb index 3312d81f..a922d750 100644 --- a/lib/appwrite/query.rb +++ b/lib/appwrite/query.rb @@ -216,6 +216,15 @@ def elem_match(attribute, queries) return Query.new("elemMatch", attribute, queries.map { |query| JSON.parse(query) }).to_s end + # Constrain populated related documents on a relationship attribute. + # + # @param attribute [String] The relationship attribute to query. + # @param queries [Array] Filter, order, select, and pagination queries applied to related documents. + # @return [String] The query string. + def relationship(attribute, queries) + return Query.new("relationship", attribute, queries.map { |query| JSON.parse(query) }).to_s + end + def distance_equal(attribute, values, distance, meters = true) return Query.new("distanceEqual", attribute, [[values, distance, meters]]).to_s end @@ -275,6 +284,187 @@ def touches(attribute, values) def not_touches(attribute, values) return Query.new("notTouches", attribute, [values]).to_s end + + def count(attribute = '*', alias_name = '') + return Query.new("count", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def count_distinct(attribute, alias_name = '') + return Query.new("countDistinct", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def sum(attribute, alias_name = '') + return Query.new("sum", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def avg(attribute, alias_name = '') + return Query.new("avg", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def min(attribute, alias_name = '') + return Query.new("min", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def max(attribute, alias_name = '') + return Query.new("max", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def stddev(attribute, alias_name = '') + return Query.new("stddev", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def stddev_pop(attribute, alias_name = '') + return Query.new("stddevPop", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def stddev_samp(attribute, alias_name = '') + return Query.new("stddevSamp", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def variance(attribute, alias_name = '') + return Query.new("variance", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def var_pop(attribute, alias_name = '') + return Query.new("varPop", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def var_samp(attribute, alias_name = '') + return Query.new("varSamp", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def bit_and(attribute, alias_name = '') + return Query.new("bitAnd", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def bit_or(attribute, alias_name = '') + return Query.new("bitOr", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def bit_xor(attribute, alias_name = '') + return Query.new("bitXor", attribute, alias_name != '' ? alias_name : nil).to_s + end + + def group_by(attributes) + return Query.new("groupBy", nil, attributes).to_s + end + + def having(queries) + return Query.new("having", nil, queries.map { |query| JSON.parse(query) }).to_s + end + + def distinct() + return Query.new("distinct", nil, nil).to_s + end + + def on(left, right, operator = '=') + return Query.new("on", nil, [left, operator, right]).to_s + end + + def join(table, left, right = '', operator = '=', alias_name = '') + return create_join("join", table, left, right, operator, alias_name) + end + + def left_join(table, left, right = '', operator = '=', alias_name = '') + return create_join("leftJoin", table, left, right, operator, alias_name) + end + + def right_join(table, left, right = '', operator = '=', alias_name = '') + return create_join("rightJoin", table, left, right, operator, alias_name) + end + + def full_outer_join(table, left, right = '', operator = '=', alias_name = '') + return create_join("fullOuterJoin", table, left, right, operator, alias_name) + end + + def cross_join(table, alias_name = '') + return Query.new("crossJoin", table, alias_name != '' ? alias_name : nil).to_s + end + + def covers(attribute, values) + return Query.new("covers", attribute, [values]).to_s + end + + def not_covers(attribute, values) + return Query.new("notCovers", attribute, [values]).to_s + end + + def spatial_equals(attribute, values) + return Query.new("spatialEquals", attribute, [values]).to_s + end + + def not_spatial_equals(attribute, values) + return Query.new("notSpatialEquals", attribute, [values]).to_s + end + + def page(page, per_page = 25) + if page < 1 + raise ArgumentError, "Page must be >= 1, got #{page}" + end + if per_page < 1 + raise ArgumentError, "Per page must be >= 1, got #{per_page}" + end + + return [ + limit(per_page), + offset((page - 1) * per_page), + ] + end + + def builder + return Builder.new + end + + def _flatten(value) + return value.build if value.is_a?(Builder) + return value.to_s if value.is_a?(Query) + return value unless value.is_a?(Array) + + out = [] + changed = false + value.each do |item| + flat = _flatten(item) + if item.is_a?(Builder) || item.is_a?(Query) + if flat.is_a?(Array) + out.concat(flat) + else + out << flat + end + changed = true + next + end + changed = true if flat != item + out << flat + end + + changed ? out : value + end + + private + + def create_join(method, table, left, right, operator, alias_name) + return nested_join(method, table, '', left) if left.is_a?(Array) + return nested_join(method, table, left, right) if right.is_a?(Array) + + return join_query(method, table, left, right, operator, alias_name) + end + + def nested_join(method, table, alias_name, on) + values = [] + values << alias_name if alias_name != '' + on.each { |query| values << JSON.parse(query) } + + return Query.new(method, table, values).to_s + end + + def join_query(method, table, left, right, operator, alias_name) + values = [left, operator, right] + values << alias_name if alias_name != '' + + return Query.new(method, table, values).to_s + end end end + + require_relative 'query/builder' end diff --git a/lib/appwrite/query/builder.rb b/lib/appwrite/query/builder.rb new file mode 100644 index 00000000..8f914b0e --- /dev/null +++ b/lib/appwrite/query/builder.rb @@ -0,0 +1,361 @@ +require 'json' + +module Appwrite + class Query::Builder + def initialize + @queries = [] + end + + def build + return @queries.dup + end + + def equal(attribute, value) + return push(Query.equal(attribute, value)) + end + + def not_equal(attribute, value) + return push(Query.not_equal(attribute, value)) + end + + def less_than(attribute, value) + return push(Query.less_than(attribute, value)) + end + + def less_than_equal(attribute, value) + return push(Query.less_than_equal(attribute, value)) + end + + def greater_than(attribute, value) + return push(Query.greater_than(attribute, value)) + end + + def greater_than_equal(attribute, value) + return push(Query.greater_than_equal(attribute, value)) + end + + def search(attribute, value) + return push(Query.search(attribute, value)) + end + + def is_null(attribute) + return push(Query.is_null(attribute)) + end + + def is_not_null(attribute) + return push(Query.is_not_null(attribute)) + end + + def between(attribute, start, ending) + return push(Query.between(attribute, start, ending)) + end + + def starts_with(attribute, value) + return push(Query.starts_with(attribute, value)) + end + + def ends_with(attribute, value) + return push(Query.ends_with(attribute, value)) + end + + def select(attributes) + return push(Query.select(attributes)) + end + + def cursor_after(id) + return push(Query.cursor_after(id)) + end + + def cursor_before(id) + return push(Query.cursor_before(id)) + end + + def order_asc(attribute) + return push(Query.order_asc(attribute)) + end + + def order_desc(attribute) + return push(Query.order_desc(attribute)) + end + + def order_random() + return push(Query.order_random()) + end + + def limit(limit) + return push(Query.limit(limit)) + end + + def offset(offset) + return push(Query.offset(offset)) + end + + def contains(attribute, value) + return push(Query.contains(attribute, value)) + end + + def contains_any(attribute, value) + return push(Query.contains_any(attribute, value)) + end + + def contains_all(attribute, value) + return push(Query.contains_all(attribute, value)) + end + + def not_contains(attribute, value) + return push(Query.not_contains(attribute, value)) + end + + def not_search(attribute, value) + return push(Query.not_search(attribute, value)) + end + + def not_between(attribute, start, ending) + return push(Query.not_between(attribute, start, ending)) + end + + def not_starts_with(attribute, value) + return push(Query.not_starts_with(attribute, value)) + end + + def not_ends_with(attribute, value) + return push(Query.not_ends_with(attribute, value)) + end + + def regex(attribute, pattern) + return push(Query.regex(attribute, pattern)) + end + + def exists(attributes) + return push(Query.exists(attributes)) + end + + def not_exists(attributes) + return push(Query.not_exists(attributes)) + end + + def created_before(value) + return push(Query.created_before(value)) + end + + def created_after(value) + return push(Query.created_after(value)) + end + + def created_between(start, ending) + return push(Query.created_between(start, ending)) + end + + def updated_before(value) + return push(Query.updated_before(value)) + end + + def updated_after(value) + return push(Query.updated_after(value)) + end + + def updated_between(start, ending) + return push(Query.updated_between(start, ending)) + end + + def or(queries) + return push(Query.or(queries)) + end + + def and(queries) + return push(Query.and(queries)) + end + + def elem_match(attribute, queries) + return push(Query.elem_match(attribute, queries)) + end + + def relationship(attribute, queries) + return push(Query.relationship(attribute, queries)) + end + + def distance_equal(attribute, values, distance, meters = true) + return push(Query.distance_equal(attribute, values, distance, meters)) + end + + def distance_not_equal(attribute, values, distance, meters = true) + return push(Query.distance_not_equal(attribute, values, distance, meters)) + end + + def distance_greater_than(attribute, values, distance, meters = true) + return push(Query.distance_greater_than(attribute, values, distance, meters)) + end + + def distance_less_than(attribute, values, distance, meters = true) + return push(Query.distance_less_than(attribute, values, distance, meters)) + end + + def intersects(attribute, values) + return push(Query.intersects(attribute, values)) + end + + def not_intersects(attribute, values) + return push(Query.not_intersects(attribute, values)) + end + + def crosses(attribute, values) + return push(Query.crosses(attribute, values)) + end + + def not_crosses(attribute, values) + return push(Query.not_crosses(attribute, values)) + end + + def overlaps(attribute, values) + return push(Query.overlaps(attribute, values)) + end + + def not_overlaps(attribute, values) + return push(Query.not_overlaps(attribute, values)) + end + + def touches(attribute, values) + return push(Query.touches(attribute, values)) + end + + def not_touches(attribute, values) + return push(Query.not_touches(attribute, values)) + end + + def count(attribute = '*', alias_name = '') + return push(Query.count(attribute, alias_name)) + end + + def count_distinct(attribute, alias_name = '') + return push(Query.count_distinct(attribute, alias_name)) + end + + def sum(attribute, alias_name = '') + return push(Query.sum(attribute, alias_name)) + end + + def avg(attribute, alias_name = '') + return push(Query.avg(attribute, alias_name)) + end + + def min(attribute, alias_name = '') + return push(Query.min(attribute, alias_name)) + end + + def max(attribute, alias_name = '') + return push(Query.max(attribute, alias_name)) + end + + def stddev(attribute, alias_name = '') + return push(Query.stddev(attribute, alias_name)) + end + + def stddev_pop(attribute, alias_name = '') + return push(Query.stddev_pop(attribute, alias_name)) + end + + def stddev_samp(attribute, alias_name = '') + return push(Query.stddev_samp(attribute, alias_name)) + end + + def variance(attribute, alias_name = '') + return push(Query.variance(attribute, alias_name)) + end + + def var_pop(attribute, alias_name = '') + return push(Query.var_pop(attribute, alias_name)) + end + + def var_samp(attribute, alias_name = '') + return push(Query.var_samp(attribute, alias_name)) + end + + def bit_and(attribute, alias_name = '') + return push(Query.bit_and(attribute, alias_name)) + end + + def bit_or(attribute, alias_name = '') + return push(Query.bit_or(attribute, alias_name)) + end + + def bit_xor(attribute, alias_name = '') + return push(Query.bit_xor(attribute, alias_name)) + end + + def group_by(attributes) + return push(Query.group_by(attributes)) + end + + def having(queries) + return push(Query.having(queries)) + end + + def distinct() + return push(Query.distinct()) + end + + def join(table, left, right = '', operator = '=', alias_name = '') + return push(Query.join(table, left, right, operator, alias_name)) + end + + def left_join(table, left, right = '', operator = '=', alias_name = '') + return push(Query.left_join(table, left, right, operator, alias_name)) + end + + def right_join(table, left, right = '', operator = '=', alias_name = '') + return push(Query.right_join(table, left, right, operator, alias_name)) + end + + def full_outer_join(table, left, right = '', operator = '=', alias_name = '') + return push(Query.full_outer_join(table, left, right, operator, alias_name)) + end + + def cross_join(table, alias_name = '') + return push(Query.cross_join(table, alias_name)) + end + + def vector_dot(attribute, vector) + return push(Query.vector_dot(attribute, vector)) + end + + def vector_cosine(attribute, vector) + return push(Query.vector_cosine(attribute, vector)) + end + + def vector_euclidean(attribute, vector) + return push(Query.vector_euclidean(attribute, vector)) + end + + def covers(attribute, values) + return push(Query.covers(attribute, values)) + end + + def not_covers(attribute, values) + return push(Query.not_covers(attribute, values)) + end + + def spatial_equals(attribute, values) + return push(Query.spatial_equals(attribute, values)) + end + + def not_spatial_equals(attribute, values) + return push(Query.not_spatial_equals(attribute, values)) + end + + def page(page, per_page = 25) + return push(Query.page(page, per_page)) + end + + private + + def push(query) + if query.is_a?(Array) + @queries.concat(query) + else + @queries << query + end + + return self + end + end +end diff --git a/lib/appwrite/services/account.rb b/lib/appwrite/services/account.rb index 837b7cb8..2e21f2a1 100644 --- a/lib/appwrite/services/account.rb +++ b/lib/appwrite/services/account.rb @@ -49,8 +49,6 @@ def create( password:, name: nil ) - api_path = '/account' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -63,6 +61,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account' + api_params = { userId: user_id, email: email, @@ -126,13 +126,13 @@ def list_consents( def get_consent( consent_id: ) - api_path = '/account/consents/{consentId}' - .gsub('{consentId}', consent_id) - - if consent_id.nil? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end + api_path = '/account/consents/{consentId}' + .gsub('{consentId}', consent_id) + api_params = {} api_headers = { @@ -159,13 +159,13 @@ def get_consent( def delete_consent( consent_id: ) - api_path = '/account/consents/{consentId}' - .gsub('{consentId}', consent_id) - - if consent_id.nil? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end + api_path = '/account/consents/{consentId}' + .gsub('{consentId}', consent_id) + api_params = {} api_headers = { @@ -196,13 +196,13 @@ def list_consent_tokens( queries: nil, total: nil ) - api_path = '/account/consents/{consentId}/tokens' - .gsub('{consentId}', consent_id) - - if consent_id.nil? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end + api_path = '/account/consents/{consentId}/tokens' + .gsub('{consentId}', consent_id) + api_params = { queries: queries, total: total, @@ -233,18 +233,18 @@ 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? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/account/consents/{consentId}/tokens/{tokenId}' + .gsub('{consentId}', consent_id) + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { @@ -273,18 +273,18 @@ 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? + if consent_id.nil? || consent_id == '' raise Appwrite::Exception.new('Missing required parameter: "consentId"') end - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/account/consents/{consentId}/tokens/{tokenId}' + .gsub('{consentId}', consent_id) + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { @@ -318,8 +318,6 @@ def update_email( email:, password: ) - api_path = '/account/email' - if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end @@ -328,6 +326,8 @@ def update_email( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/email' + api_params = { email: email, password: password, @@ -387,57 +387,26 @@ def list_identities( def delete_identity( identity_id: ) - api_path = '/account/identities/{identityId}' - .gsub('{identityId}', identity_id) - - if identity_id.nil? + if identity_id.nil? || identity_id == '' raise Appwrite::Exception.new('Missing required parameter: "identityId"') end + api_path = '/account/identities/{identityId}' + .gsub('{identityId}', identity_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', - } - - @client.call( - method: 'DELETE', - path: api_path, - headers: api_headers, - params: api_params, - ) - end - - # Get the list of latest security activity logs for the currently logged in - # user. Each log returns user IP address, location and date and time of log. - # - # @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). Only supported methods are limit and offset - # @param [] total When set to false, the total count returned will be 0 and will not be calculated. - # - # @return [LogList] - def list_logs( - queries: nil, - total: nil - ) - api_path = '/account/logs' - - api_params = { - queries: queries, - total: total, - } - - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), "accept": 'application/json', } @client.call( - method: 'GET', + method: 'DELETE', path: api_path, headers: api_headers, params: api_params, - response_type: Models::LogList ) end @@ -449,12 +418,12 @@ def list_logs( def update_mfa( mfa: ) - api_path = '/account/mfa' - if mfa.nil? raise Appwrite::Exception.new('Missing required parameter: "mfa"') end + api_path = '/account/mfa' + api_params = { mfa: mfa, } @@ -485,13 +454,13 @@ def update_mfa( def create_mfa_authenticator( type: ) - api_path = '/account/mfa/authenticators/{type}' - .gsub('{type}', type) - if type.nil? raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/account/mfa/authenticators/{type}' + .gsub('{type}', type) + api_params = {} api_headers = { @@ -521,9 +490,6 @@ def update_mfa_authenticator( type:, otp: ) - api_path = '/account/mfa/authenticators/{type}' - .gsub('{type}', type) - if type.nil? raise Appwrite::Exception.new('Missing required parameter: "type"') end @@ -532,6 +498,9 @@ def update_mfa_authenticator( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/account/mfa/authenticators/{type}' + .gsub('{type}', type) + api_params = { otp: otp, } @@ -559,18 +528,19 @@ def update_mfa_authenticator( def delete_mfa_authenticator( type: ) - api_path = '/account/mfa/authenticators/{type}' - .gsub('{type}', type) - if type.nil? raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/account/mfa/authenticators/{type}' + .gsub('{type}', type) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -591,12 +561,12 @@ def delete_mfa_authenticator( def create_mfa_challenge( factor: ) - api_path = '/account/mfa/challenges' - if factor.nil? raise Appwrite::Exception.new('Missing required parameter: "factor"') end + api_path = '/account/mfa/challenges' + api_params = { factor: factor, } @@ -630,8 +600,6 @@ def update_mfa_challenge( challenge_id:, otp: ) - api_path = '/account/mfa/challenges' - if challenge_id.nil? raise Appwrite::Exception.new('Missing required parameter: "challengeId"') end @@ -640,6 +608,8 @@ def update_mfa_challenge( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/account/mfa/challenges' + api_params = { challengeId: challenge_id, otp: otp, @@ -772,12 +742,12 @@ def update_mfa_recovery_codes() def update_name( name: ) - api_path = '/account/name' - if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/account/name' + api_params = { name: name, } @@ -1029,12 +999,12 @@ def update_password( password:, old_password: nil ) - api_path = '/account/password' - if password.nil? raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/password' + api_params = { password: password, oldPassword: old_password, @@ -1069,8 +1039,6 @@ def update_phone( phone:, password: ) - api_path = '/account/phone' - if phone.nil? raise Appwrite::Exception.new('Missing required parameter: "phone"') end @@ -1079,6 +1047,8 @@ def update_phone( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/phone' + api_params = { phone: phone, password: password, @@ -1132,12 +1102,12 @@ def get_prefs() def update_prefs( prefs: ) - api_path = '/account/prefs' - if prefs.nil? raise Appwrite::Exception.new('Missing required parameter: "prefs"') end + api_path = '/account/prefs' + api_params = { prefs: prefs, } @@ -1174,8 +1144,6 @@ def create_recovery( email:, url: ) - api_path = '/account/recovery' - if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end @@ -1184,6 +1152,8 @@ def create_recovery( raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/account/recovery' + api_params = { email: email, url: url, @@ -1225,8 +1195,6 @@ def update_recovery( secret:, password: ) - api_path = '/account/recovery' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1239,6 +1207,8 @@ def update_recovery( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/recovery' + api_params = { userId: user_id, secret: secret, @@ -1392,7 +1362,8 @@ def list_sessions( end # Delete all sessions from the user account and remove any sessions cookies - # from the end client. + # from the end client. Pass `current` as false to keep the session making the + # request and sign out of every other session. # # @param [] current Delete the current session too. Use false to sign out of every other session while staying signed in on this one. # @@ -1409,6 +1380,7 @@ def delete_sessions( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1451,6 +1423,9 @@ def create_anonymous_session() # Allow the user to login into their account by providing a valid email and # password combination. This route will create a new session for the user. + # Use the optional `duration` parameter to create a shorter session, for + # example when the user doesn't choose "remember me". It must be at least 60 + # seconds and cannot exceed the project maximum session length. # # A user is limited to 10 active sessions at a time by default. [Learn more # about session @@ -1466,8 +1441,6 @@ def create_email_password_session( password:, duration: nil ) - api_path = '/account/sessions/email' - if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end @@ -1476,6 +1449,8 @@ def create_email_password_session( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/sessions/email' + api_params = { email: email, password: password, @@ -1605,8 +1580,6 @@ def update_magic_url_session( user_id:, secret: ) - api_path = '/account/sessions/magic-url' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1615,6 +1588,8 @@ def update_magic_url_session( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/sessions/magic-url' + api_params = { userId: user_id, secret: secret, @@ -1650,8 +1625,6 @@ def update_phone_session( user_id:, secret: ) - api_path = '/account/sessions/phone' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1660,6 +1633,8 @@ def update_phone_session( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/sessions/phone' + api_params = { userId: user_id, secret: secret, @@ -1692,8 +1667,6 @@ def create_session( user_id:, secret: ) - api_path = '/account/sessions/token' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1702,6 +1675,8 @@ def create_session( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/sessions/token' + api_params = { userId: user_id, secret: secret, @@ -1731,13 +1706,13 @@ def create_session( def get_session( session_id: ) - api_path = '/account/sessions/{sessionId}' - .gsub('{sessionId}', session_id) - - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/account/sessions/{sessionId}' + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { @@ -1764,13 +1739,13 @@ def get_session( def update_session( session_id: ) - api_path = '/account/sessions/{sessionId}' - .gsub('{sessionId}', session_id) - - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/account/sessions/{sessionId}' + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { @@ -1800,18 +1775,19 @@ def update_session( def delete_session( session_id: ) - api_path = '/account/sessions/{sessionId}' - .gsub('{sessionId}', session_id) - - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/account/sessions/{sessionId}' + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1873,8 +1849,6 @@ def create_email_token( email:, phrase: nil ) - api_path = '/account/tokens/email' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1883,6 +1857,8 @@ def create_email_token( raise Appwrite::Exception.new('Missing required parameter: "email"') end + api_path = '/account/tokens/email' + api_params = { userId: user_id, email: email, @@ -1931,8 +1907,6 @@ def create_magic_url_token( url: nil, phrase: nil ) - api_path = '/account/tokens/magic-url' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1941,6 +1915,8 @@ def create_magic_url_token( raise Appwrite::Exception.new('Missing required parameter: "email"') end + api_path = '/account/tokens/magic-url' + api_params = { userId: user_id, email: email, @@ -1974,11 +1950,15 @@ def create_magic_url_token( # session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) # endpoint. # + # If there is already an active session, the OAuth2 identity is attached to + # the logged-in account and that session stays active until the token is + # exchanged for a new one. + # # A user is limited to 10 active sessions at a time by default. [Learn more # about session # limits](https://appwrite.io/docs/authentication-security#limits). # - # @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. + # @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom. # @param [String] success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. # @param [String] failure URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. # @param [Array] scopes A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. @@ -1992,13 +1972,13 @@ def create_o_auth2_token( scopes: nil, state: nil ) - api_path = '/account/tokens/oauth2/{provider}' - .gsub('{provider}', provider) - if provider.nil? raise Appwrite::Exception.new('Missing required parameter: "provider"') end + api_path = '/account/tokens/oauth2/{provider}' + .gsub('{provider}', provider) + api_params = { success: success, failure: failure, @@ -2117,8 +2097,6 @@ def create_phone_token( user_id:, phone: ) - api_path = '/account/tokens/phone' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2127,6 +2105,8 @@ def create_phone_token( raise Appwrite::Exception.new('Missing required parameter: "phone"') end + api_path = '/account/tokens/phone' + api_params = { userId: user_id, phone: phone, @@ -2169,12 +2149,12 @@ def create_phone_token( def create_email_verification( url: ) - api_path = '/account/verifications/email' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/account/verifications/email' + api_params = { url: url, } @@ -2219,12 +2199,12 @@ def create_email_verification( def create_verification( url: ) - api_path = '/account/verifications/email' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/account/verifications/email' + api_params = { url: url, } @@ -2257,8 +2237,6 @@ def update_email_verification( user_id:, secret: ) - api_path = '/account/verifications/email' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2267,6 +2245,8 @@ def update_email_verification( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/verifications/email' + api_params = { userId: user_id, secret: secret, @@ -2303,8 +2283,6 @@ def update_verification( user_id:, secret: ) - api_path = '/account/verifications/email' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2313,6 +2291,8 @@ def update_verification( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/verifications/email' + api_params = { userId: user_id, secret: secret, @@ -2465,8 +2445,6 @@ def update_phone_verification( user_id:, secret: ) - api_path = '/account/verifications/phone' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2475,6 +2453,8 @@ def update_phone_verification( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/verifications/phone' + api_params = { userId: user_id, secret: secret, diff --git a/lib/appwrite/services/activities.rb b/lib/appwrite/services/activities.rb index 2c4c457f..e6030e18 100644 --- a/lib/appwrite/services/activities.rb +++ b/lib/appwrite/services/activities.rb @@ -43,13 +43,13 @@ def list_events( def get_event( event_id: ) - api_path = '/activities/events/{eventId}' - .gsub('{eventId}', event_id) - - if event_id.nil? + if event_id.nil? || event_id == '' raise Appwrite::Exception.new('Missing required parameter: "eventId"') end + api_path = '/activities/events/{eventId}' + .gsub('{eventId}', event_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/advisor.rb b/lib/appwrite/services/advisor.rb index 7efe9fa7..180fb950 100644 --- a/lib/appwrite/services/advisor.rb +++ b/lib/appwrite/services/advisor.rb @@ -49,13 +49,13 @@ def list_reports( def get_report( report_id: ) - api_path = '/reports/{reportId}' - .gsub('{reportId}', report_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end + api_path = '/reports/{reportId}' + .gsub('{reportId}', report_id) + api_params = {} api_headers = { @@ -82,18 +82,19 @@ def get_report( def delete_report( report_id: ) - api_path = '/reports/{reportId}' - .gsub('{reportId}', report_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end + api_path = '/reports/{reportId}' + .gsub('{reportId}', report_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -118,13 +119,13 @@ def list_insights( queries: nil, total: nil ) - api_path = '/reports/{reportId}/insights' - .gsub('{reportId}', report_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end + api_path = '/reports/{reportId}/insights' + .gsub('{reportId}', report_id) + api_params = { queries: queries, total: total, @@ -155,18 +156,18 @@ def get_insight( report_id:, insight_id: ) - api_path = '/reports/{reportId}/insights/{insightId}' - .gsub('{reportId}', report_id) - .gsub('{insightId}', insight_id) - - if report_id.nil? + if report_id.nil? || report_id == '' raise Appwrite::Exception.new('Missing required parameter: "reportId"') end - if insight_id.nil? + if insight_id.nil? || insight_id == '' raise Appwrite::Exception.new('Missing required parameter: "insightId"') end + api_path = '/reports/{reportId}/insights/{insightId}' + .gsub('{reportId}', report_id) + .gsub('{insightId}', insight_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/apps.rb b/lib/appwrite/services/apps.rb index c4c15c1f..ceeb7dca 100644 --- a/lib/appwrite/services/apps.rb +++ b/lib/appwrite/services/apps.rb @@ -81,8 +81,6 @@ def create( device_flow: nil, team_id: nil ) - api_path = '/apps' - if app_id.nil? raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -95,6 +93,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "redirectUris"') end + api_path = '/apps' + api_params = { appId: app_id, name: name, @@ -186,13 +186,13 @@ def list_o_auth2_scopes() def get( app_id: ) - api_path = '/apps/{appId}' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -255,10 +255,7 @@ def update( installation_scopes: nil, installation_redirect_url: nil ) - api_path = '/apps/{appId}' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -266,6 +263,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/apps/{appId}' + .gsub('{appId}', app_id) + api_params = { name: name, description: description, @@ -311,13 +311,13 @@ def update( def delete( app_id: ) - api_path = '/apps/{appId}' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -348,13 +348,13 @@ def list_installations( queries: nil, total: nil ) - api_path = '/apps/{appId}/installations' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/installations' + .gsub('{appId}', app_id) + api_params = { queries: queries, total: total, @@ -386,18 +386,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/apps/{appId}/installations/{installationId}' + .gsub('{appId}', app_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -426,18 +426,18 @@ def delete_installation( app_id:, installation_id: ) - api_path = '/apps/{appId}/installations/{installationId}' - .gsub('{appId}', app_id) - .gsub('{installationId}', installation_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/apps/{appId}/installations/{installationId}' + .gsub('{appId}', app_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -471,18 +471,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/apps/{appId}/installations/{installationId}/tokens' + .gsub('{appId}', app_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -512,13 +512,13 @@ def list_keys( queries: nil, total: nil ) - api_path = '/apps/{appId}/keys' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/keys' + .gsub('{appId}', app_id) + api_params = { queries: queries, total: total, @@ -548,13 +548,13 @@ def list_keys( def create_key( app_id: ) - api_path = '/apps/{appId}/keys' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/keys' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -582,18 +582,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/apps/{appId}/keys/{keyId}' + .gsub('{appId}', app_id) + .gsub('{keyId}', key_id) + api_params = {} api_headers = { @@ -620,18 +620,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/apps/{appId}/keys/{keyId}' + .gsub('{appId}', app_id) + .gsub('{keyId}', key_id) + api_params = {} api_headers = { @@ -653,17 +653,14 @@ def delete_key( # 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. + # @param [Array] labels Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. Reserved labels are rejected. # # @return [App] def update_labels( app_id:, labels: ) - api_path = '/apps/{appId}/labels' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -671,6 +668,9 @@ def update_labels( raise Appwrite::Exception.new('Missing required parameter: "labels"') end + api_path = '/apps/{appId}/labels' + .gsub('{appId}', app_id) + api_params = { labels: labels, } @@ -702,13 +702,13 @@ def list_secrets( queries: nil, total: nil ) - api_path = '/apps/{appId}/secrets' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/secrets' + .gsub('{appId}', app_id) + api_params = { queries: queries, total: total, @@ -736,13 +736,13 @@ def list_secrets( def create_secret( app_id: ) - api_path = '/apps/{appId}/secrets' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/secrets' + .gsub('{appId}', app_id) + api_params = {} api_headers = { @@ -770,18 +770,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if secret_id.nil? + if secret_id.nil? || secret_id == '' raise Appwrite::Exception.new('Missing required parameter: "secretId"') end + api_path = '/apps/{appId}/secrets/{secretId}' + .gsub('{appId}', app_id) + .gsub('{secretId}', secret_id) + api_params = {} api_headers = { @@ -808,18 +808,18 @@ 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? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end - if secret_id.nil? + if secret_id.nil? || secret_id == '' raise Appwrite::Exception.new('Missing required parameter: "secretId"') end + api_path = '/apps/{appId}/secrets/{secretId}' + .gsub('{appId}', app_id) + .gsub('{secretId}', secret_id) + api_params = {} api_headers = { @@ -846,10 +846,7 @@ def update_team( app_id:, team_id: ) - api_path = '/apps/{appId}/team' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end @@ -857,6 +854,9 @@ def update_team( raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/apps/{appId}/team' + .gsub('{appId}', app_id) + api_params = { teamId: team_id, } @@ -884,13 +884,13 @@ def update_team( def delete_tokens( app_id: ) - api_path = '/apps/{appId}/tokens' - .gsub('{appId}', app_id) - - if app_id.nil? + if app_id.nil? || app_id == '' raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/apps/{appId}/tokens' + .gsub('{appId}', app_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/avatars.rb b/lib/appwrite/services/avatars.rb index d3ab6a03..1555c4f2 100644 --- a/lib/appwrite/services/avatars.rb +++ b/lib/appwrite/services/avatars.rb @@ -29,13 +29,13 @@ def get_browser( height: nil, quality: nil ) - api_path = '/avatars/browsers/{code}' - .gsub('{code}', code) - if code.nil? raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/avatars/browsers/{code}' + .gsub('{code}', code) + api_params = { width: width, height: height, @@ -77,13 +77,13 @@ def get_credit_card( height: nil, quality: nil ) - api_path = '/avatars/credit-cards/{code}' - .gsub('{code}', code) - if code.nil? raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/avatars/credit-cards/{code}' + .gsub('{code}', code) + api_params = { width: width, height: height, @@ -114,12 +114,12 @@ def get_credit_card( def get_favicon( url: ) - api_path = '/avatars/favicon' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/avatars/favicon' + api_params = { url: url, } @@ -160,13 +160,13 @@ def get_flag( height: nil, quality: nil ) - api_path = '/avatars/flags/{code}' - .gsub('{code}', code) - if code.nil? raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/avatars/flags/{code}' + .gsub('{code}', code) + api_params = { width: width, height: height, @@ -208,12 +208,12 @@ def get_image( width: nil, height: nil ) - api_path = '/avatars/image' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/avatars/image' + api_params = { url: url, width: width, @@ -285,9 +285,9 @@ def get_initials( end # Returns the best available profile photo for a user. The endpoint tries - # each source in priority order and returns the first successful result: - # OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in - # static fallback. + # each source in priority order and returns the first successful result: a + # custom uploaded photo (see avatars.updatePhoto), OAuth2 identity photo, + # Gravatar, Libravatar, Appwrite Initials, built-in static fallback. # # Passing `userId` — `current()` for the authenticated user — resolves # the photo from everything known about that user: identity photos, email, @@ -433,12 +433,12 @@ def get_qr( margin: nil, download: nil ) - api_path = '/avatars/qr' - if text.nil? raise Appwrite::Exception.new('Missing required parameter: "text"') end + api_path = '/avatars/qr' + api_params = { text: text, size: size, @@ -471,7 +471,7 @@ def get_qr( # dimensions are not specified, the default viewport size is 1280x720px. # # @param [String] url Website URL which you want to capture. - # @param [Hash] headers HTTP headers to send with the browser request. Defaults to empty. + # @param [Hash] headers HTTP headers to send with the browser request. Only Accept and Accept-Language are allowed. Defaults to empty. # @param [Integer] viewport_width Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. # @param [Integer] viewport_height Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720. # @param [Float] scale Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1. @@ -514,12 +514,12 @@ def get_screenshot( quality: nil, output: nil ) - api_path = '/avatars/screenshots' - if url.nil? raise Appwrite::Exception.new('Missing required parameter: "url"') end + api_path = '/avatars/screenshots' + api_params = { url: url, headers: headers, diff --git a/lib/appwrite/services/backups.rb b/lib/appwrite/services/backups.rb index f74a5917..9d58c7bf 100644 --- a/lib/appwrite/services/backups.rb +++ b/lib/appwrite/services/backups.rb @@ -44,12 +44,12 @@ def create_archive( services:, resource_id: nil ) - api_path = '/backups/archives' - if services.nil? raise Appwrite::Exception.new('Missing required parameter: "services"') end + api_path = '/backups/archives' + api_params = { services: services, resourceId: resource_id, @@ -78,13 +78,13 @@ def create_archive( def get_archive( archive_id: ) - api_path = '/backups/archives/{archiveId}' - .gsub('{archiveId}', archive_id) - - if archive_id.nil? + if archive_id.nil? || archive_id == '' raise Appwrite::Exception.new('Missing required parameter: "archiveId"') end + api_path = '/backups/archives/{archiveId}' + .gsub('{archiveId}', archive_id) + api_params = {} api_headers = { @@ -109,13 +109,13 @@ def get_archive( def delete_archive( archive_id: ) - api_path = '/backups/archives/{archiveId}' - .gsub('{archiveId}', archive_id) - - if archive_id.nil? + if archive_id.nil? || archive_id == '' raise Appwrite::Exception.new('Missing required parameter: "archiveId"') end + api_path = '/backups/archives/{archiveId}' + .gsub('{archiveId}', archive_id) + api_params = {} api_headers = { @@ -180,8 +180,6 @@ def create_policy( resource_id: nil, enabled: nil ) - api_path = '/backups/policies' - if policy_id.nil? raise Appwrite::Exception.new('Missing required parameter: "policyId"') end @@ -198,6 +196,8 @@ def create_policy( raise Appwrite::Exception.new('Missing required parameter: "schedule"') end + api_path = '/backups/policies' + api_params = { policyId: policy_id, name: name, @@ -231,13 +231,13 @@ def create_policy( def get_policy( policy_id: ) - api_path = '/backups/policies/{policyId}' - .gsub('{policyId}', policy_id) - - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/backups/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -270,13 +270,13 @@ def update_policy( schedule: nil, enabled: nil ) - api_path = '/backups/policies/{policyId}' - .gsub('{policyId}', policy_id) - - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/backups/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = { name: name, retention: retention, @@ -307,13 +307,13 @@ def update_policy( def delete_policy( policy_id: ) - api_path = '/backups/policies/{policyId}' - .gsub('{policyId}', policy_id) - - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/backups/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -375,8 +375,6 @@ def create_restoration( new_resource_id: nil, new_resource_name: nil ) - api_path = '/backups/restoration' - if archive_id.nil? raise Appwrite::Exception.new('Missing required parameter: "archiveId"') end @@ -385,6 +383,8 @@ def create_restoration( raise Appwrite::Exception.new('Missing required parameter: "services"') end + api_path = '/backups/restoration' + api_params = { archiveId: archive_id, services: services, @@ -443,13 +443,13 @@ def list_restorations( def get_restoration( restoration_id: ) - api_path = '/backups/restorations/{restorationId}' - .gsub('{restorationId}', restoration_id) - - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/backups/restorations/{restorationId}' + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/databases.rb b/lib/appwrite/services/databases.rb index c8783184..46bb76c1 100644 --- a/lib/appwrite/services/databases.rb +++ b/lib/appwrite/services/databases.rb @@ -60,8 +60,6 @@ def create( name:, enabled: nil ) - api_path = '/databases' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -70,6 +68,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/databases' + api_params = { databaseId: database_id, name: name, @@ -168,13 +168,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/databases/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -206,13 +206,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/databases/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -244,18 +244,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/databases/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -279,13 +280,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/databases/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/databases/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -317,13 +318,13 @@ def create_operations( def get( database_id: ) - api_path = '/databases/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -355,13 +356,13 @@ def update( name: nil, enabled: nil ) - api_path = '/databases/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -394,18 +395,19 @@ def update( def delete( database_id: ) - api_path = '/databases/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -434,13 +436,13 @@ def list_collections( search: nil, total: nil ) - api_path = '/databases/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/databases/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -476,7 +478,7 @@ def list_collections( # @param [] document_security Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] enabled Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. # @param [Array] attributes Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. - # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). # # @return [Collection] def create_collection( @@ -489,10 +491,7 @@ def create_collection( attributes: nil, indexes: nil ) - api_path = '/databases/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -504,6 +503,9 @@ def create_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/databases/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { collectionId: collection_id, name: name, @@ -543,18 +545,18 @@ def get_collection( database_id:, collection_id: ) - api_path = '/databases/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { @@ -594,18 +596,18 @@ def update_collection( enabled: nil, purge: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { name: name, permissions: permissions, @@ -643,23 +645,24 @@ def delete_collection( database_id:, collection_id: ) - api_path = '/databases/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -687,18 +690,18 @@ def list_attributes( queries: nil, total: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -745,15 +748,11 @@ def create_big_int_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -765,6 +764,10 @@ def create_big_int_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -816,20 +819,15 @@ def update_big_int_attribute( max: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -841,6 +839,11 @@ def update_big_int_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -886,15 +889,11 @@ def create_boolean_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -906,6 +905,10 @@ def create_boolean_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -950,20 +953,15 @@ def update_boolean_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -975,6 +973,11 @@ def update_boolean_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1017,15 +1020,11 @@ def create_datetime_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1037,6 +1036,10 @@ def create_datetime_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1081,20 +1084,15 @@ def update_datetime_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1106,6 +1104,11 @@ def update_datetime_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1149,15 +1152,11 @@ def create_email_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1169,6 +1168,10 @@ def create_email_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1214,20 +1217,15 @@ def update_email_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1239,6 +1237,11 @@ def update_email_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1285,15 +1288,11 @@ def create_enum_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1309,6 +1308,10 @@ def create_enum_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, elements: elements, @@ -1357,20 +1360,15 @@ def update_enum_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1386,6 +1384,11 @@ def update_enum_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { elements: elements, required: required, @@ -1435,15 +1438,11 @@ def create_float_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1455,6 +1454,10 @@ def create_float_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1506,20 +1509,15 @@ def update_float_attribute( max: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1531,6 +1529,11 @@ def update_float_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1581,15 +1584,11 @@ def create_integer_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1601,6 +1600,10 @@ def create_integer_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1652,20 +1655,15 @@ def update_integer_attribute( max: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1677,6 +1675,11 @@ def update_integer_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1722,15 +1725,11 @@ def create_ip_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1742,6 +1741,10 @@ def create_ip_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1787,20 +1790,15 @@ def update_ip_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1812,6 +1810,11 @@ def update_ip_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1852,15 +1855,11 @@ def create_line_attribute( required:, default: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1872,6 +1871,10 @@ def create_line_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -1915,20 +1918,15 @@ def update_line_attribute( default: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1936,6 +1934,11 @@ def update_line_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1981,15 +1984,11 @@ def create_longtext_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2001,6 +2000,10 @@ def create_longtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2047,20 +2050,15 @@ def update_longtext_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2072,6 +2070,11 @@ def update_longtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2117,15 +2120,11 @@ def create_mediumtext_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2137,6 +2136,10 @@ def create_mediumtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2183,20 +2186,15 @@ def update_mediumtext_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2208,6 +2206,11 @@ def update_mediumtext_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2248,15 +2251,11 @@ def create_point_attribute( required:, default: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2268,6 +2267,10 @@ def create_point_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2311,20 +2314,15 @@ def update_point_attribute( default: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2332,6 +2330,11 @@ def update_point_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2372,15 +2375,11 @@ def create_polygon_attribute( required:, default: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2392,6 +2391,10 @@ def create_polygon_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2435,20 +2438,15 @@ def update_polygon_attribute( default: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2456,6 +2454,11 @@ def update_polygon_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2504,15 +2507,11 @@ def create_relationship_attribute( two_way_key: nil, on_delete: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2524,6 +2523,10 @@ def create_relationship_attribute( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { relatedCollectionId: related_collection_id, type: type, @@ -2569,23 +2572,23 @@ def update_relationship_attribute( on_delete: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { onDelete: on_delete, newKey: new_key, @@ -2632,15 +2635,11 @@ def create_string_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2656,6 +2655,10 @@ def create_string_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, size: size, @@ -2705,20 +2708,15 @@ def update_string_attribute( size: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2730,6 +2728,11 @@ def update_string_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2776,15 +2779,11 @@ def create_text_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2796,6 +2795,10 @@ def create_text_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2842,20 +2845,15 @@ def update_text_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2867,6 +2865,11 @@ def update_text_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2910,15 +2913,11 @@ def create_url_attribute( default: nil, array: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -2930,6 +2929,10 @@ def create_url_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, required: required, @@ -2975,20 +2978,15 @@ def update_url_attribute( default:, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3000,6 +2998,11 @@ def update_url_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3047,15 +3050,11 @@ def create_varchar_attribute( array: nil, encrypt: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3071,6 +3070,10 @@ def create_varchar_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, size: size, @@ -3120,20 +3123,15 @@ def update_varchar_attribute( size: nil, new_key: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3145,6 +3143,11 @@ def update_varchar_attribute( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3176,29 +3179,29 @@ def update_varchar_attribute( # @param [String] collection_id Collection ID. # @param [String] key Attribute Key. # - # @return [AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributeString] + # @return [AttributeBoolean, AttributeBigint, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributePoint, AttributeLine, AttributePolygon, AttributeVarchar, AttributeText, AttributeMediumtext, AttributeLongtext, AttributeString] def get_attribute( database_id:, collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -3242,6 +3245,11 @@ def get_attribute( return Models::AttributeBoolean.from(map: response) end + if response['type'] == 'bigint' + + return Models::AttributeBigint.from(map: response) + end + if response['type'] == 'integer' return Models::AttributeInteger.from(map: response) @@ -3262,6 +3270,41 @@ def get_attribute( return Models::AttributeRelationship.from(map: response) end + if response['type'] == 'point' + + return Models::AttributePoint.from(map: response) + end + + if response['type'] == 'linestring' + + return Models::AttributeLine.from(map: response) + end + + if response['type'] == 'polygon' + + return Models::AttributePolygon.from(map: response) + end + + if response['type'] == 'varchar' + + return Models::AttributeVarchar.from(map: response) + end + + if response['type'] == 'text' + + return Models::AttributeText.from(map: response) + end + + if response['type'] == 'mediumtext' + + return Models::AttributeMediumtext.from(map: response) + end + + if response['type'] == 'longtext' + + return Models::AttributeLongtext.from(map: response) + end + if response['type'] == 'string' return Models::AttributeString.from(map: response) @@ -3285,28 +3328,29 @@ def delete_attribute( collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3339,18 +3383,18 @@ def list_documents( total: nil, ttl: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3396,15 +3440,11 @@ def create_document( permissions: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3416,6 +3456,10 @@ def create_document( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documentId: document_id, data: data, @@ -3458,15 +3502,11 @@ def create_documents( documents:, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3474,6 +3514,10 @@ def create_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -3515,15 +3559,11 @@ def upsert_documents( documents:, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -3531,6 +3571,10 @@ def upsert_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -3572,18 +3616,18 @@ def update_documents( queries: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { data: data, queries: queries, @@ -3623,18 +3667,18 @@ def delete_documents( queries: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3675,23 +3719,23 @@ def get_document( queries: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3735,23 +3779,23 @@ def upsert_document( permissions: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -3795,23 +3839,23 @@ def update_document( permissions: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -3850,23 +3894,23 @@ def delete_document( document_id:, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { transactionId: transaction_id, } @@ -3874,6 +3918,7 @@ def delete_document( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3907,28 +3952,28 @@ def decrement_document_attribute( min: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, min: min, @@ -3973,28 +4018,28 @@ def increment_document_attribute( max: nil, transaction_id: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, max: max, @@ -4033,18 +4078,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -4069,7 +4114,9 @@ def list_indexes( # # Creates an index on the attributes listed. Your index should include all # the attributes you will query in a single request. - # Attributes can be `key`, `fulltext`, and `unique`. + # Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. + # `trigram` is only available on PostgreSQL and lets `contains`, + # `startsWith`, and `endsWith` queries on string attributes use an index. # # @param [String] database_id Database ID. # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). @@ -4089,15 +4136,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -4113,6 +4156,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "attributes"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, type: type, @@ -4151,23 +4198,23 @@ def get_index( collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -4199,28 +4246,29 @@ def delete_index( collection_id:, key: ) - api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/documents_db.rb b/lib/appwrite/services/documents_db.rb index f97888a7..efa8021e 100644 --- a/lib/appwrite/services/documents_db.rb +++ b/lib/appwrite/services/documents_db.rb @@ -57,8 +57,6 @@ def create( replicas: nil, sync_mode: nil ) - api_path = '/documentsdb' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -67,6 +65,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb' + api_params = { databaseId: database_id, name: name, @@ -92,8 +92,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -184,13 +184,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/documentsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/documentsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -254,18 +254,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/documentsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -286,13 +287,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/documentsdb/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/documentsdb/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -321,13 +322,13 @@ def create_operations( def get( database_id: ) - api_path = '/documentsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -362,10 +363,7 @@ def update( replicas: nil, sync_mode: nil ) - api_path = '/documentsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -373,6 +371,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -405,18 +406,19 @@ def update( def delete( database_id: ) - api_path = '/documentsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -442,13 +444,13 @@ def list_collections( search: nil, total: nil ) - api_path = '/documentsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -494,10 +496,7 @@ def create_collection( attributes: nil, indexes: nil ) - api_path = '/documentsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -509,6 +508,9 @@ def create_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { collectionId: collection_id, name: name, @@ -545,18 +547,18 @@ def get_collection( database_id:, collection_id: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { @@ -593,15 +595,11 @@ def update_collection( enabled: nil, purge: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -609,6 +607,10 @@ def update_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { name: name, permissions: permissions, @@ -643,23 +645,24 @@ def delete_collection( database_id:, collection_id: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -689,18 +692,18 @@ def list_documents( total: nil, ttl: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -743,15 +746,11 @@ def create_document( permissions: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -763,6 +762,10 @@ def create_document( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documentId: document_id, data: data, @@ -802,15 +805,11 @@ def create_documents( documents:, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -818,6 +817,10 @@ def create_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -856,15 +859,11 @@ def upsert_documents( documents:, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -872,6 +871,10 @@ def upsert_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -910,18 +913,18 @@ def update_documents( queries: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { data: data, queries: queries, @@ -958,18 +961,18 @@ def delete_documents( queries: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1007,23 +1010,23 @@ def get_document( queries: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1064,23 +1067,23 @@ def upsert_document( permissions: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1121,23 +1124,23 @@ def update_document( permissions: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1173,23 +1176,23 @@ def delete_document( document_id:, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { transactionId: transaction_id, } @@ -1197,6 +1200,7 @@ def delete_document( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1227,28 +1231,28 @@ def decrement_document_attribute( min: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, min: min, @@ -1290,28 +1294,28 @@ def increment_document_attribute( max: nil, transaction_id: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - .gsub('{attribute}', attribute) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if attribute.nil? + if attribute.nil? || attribute == '' raise Appwrite::Exception.new('Missing required parameter: "attribute"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + .gsub('{attribute}', attribute) + api_params = { value: value, max: max, @@ -1347,18 +1351,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -1400,15 +1404,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1424,6 +1424,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "attributes"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, type: type, @@ -1459,23 +1463,23 @@ def get_index( collection_id:, key: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -1504,28 +1508,29 @@ def delete_index( collection_id:, key: ) - api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/documentsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1554,13 +1559,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/documentsdb/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1597,13 +1602,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/documentsdb/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1633,13 +1638,13 @@ def list_operations( def get_replicas( database_id: ) - api_path = '/documentsdb/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1666,13 +1671,13 @@ def get_replicas( def get_status( database_id: ) - api_path = '/documentsdb/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/documentsdb/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/domains.rb b/lib/appwrite/services/domains.rb index 3493e9e4..42937c7d 100644 --- a/lib/appwrite/services/domains.rb +++ b/lib/appwrite/services/domains.rb @@ -174,7 +174,7 @@ def list_prices( def get( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -208,7 +208,7 @@ def get( def delete( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -243,7 +243,7 @@ def update_nameservers( domain_id:, nameservers: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -281,7 +281,7 @@ def update_nameservers( def verify_nameservers( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -313,7 +313,7 @@ def verify_nameservers( def get_preset_google_workspace( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -346,7 +346,7 @@ def get_preset_google_workspace( def create_preset_google_workspace( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -378,7 +378,7 @@ def create_preset_google_workspace( def get_preset_i_cloud( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -411,7 +411,7 @@ def get_preset_i_cloud( def create_preset_i_cloud( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -443,7 +443,7 @@ def create_preset_i_cloud( def get_preset_mailgun( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -476,7 +476,7 @@ def get_preset_mailgun( def create_preset_mailgun( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -508,7 +508,7 @@ def create_preset_mailgun( def get_preset_outlook( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -541,7 +541,7 @@ def get_preset_outlook( def create_preset_outlook( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -573,7 +573,7 @@ def create_preset_outlook( def get_preset_proton_mail( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -606,7 +606,7 @@ def get_preset_proton_mail( def create_preset_proton_mail( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -638,7 +638,7 @@ def create_preset_proton_mail( def get_preset_zoho( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -671,7 +671,7 @@ def get_preset_zoho( def create_preset_zoho( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -707,7 +707,7 @@ def list_records( domain_id:, queries: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -750,7 +750,7 @@ def create_record_a( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -813,11 +813,11 @@ def update_record_a( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -878,7 +878,7 @@ def create_record_aaaa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -941,11 +941,11 @@ def update_record_aaaa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1007,7 +1007,7 @@ def create_record_alias( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1073,11 +1073,11 @@ def update_record_alias( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1138,7 +1138,7 @@ def create_record_caa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1201,11 +1201,11 @@ def update_record_caa( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1269,7 +1269,7 @@ def create_record_cname( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1328,11 +1328,11 @@ def update_record_cname( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1392,7 +1392,7 @@ def create_record_https( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1455,11 +1455,11 @@ def update_record_https( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1525,7 +1525,7 @@ def create_record_mx( priority:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1591,11 +1591,11 @@ def update_record_mx( priority:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1661,7 +1661,7 @@ def create_record_ns( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1726,11 +1726,11 @@ def update_record_ns( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1798,7 +1798,7 @@ def create_record_srv( port:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -1891,11 +1891,11 @@ def update_record_srv( port:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -1970,7 +1970,7 @@ def create_record_txt( value: nil, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2030,11 +2030,11 @@ def update_record_txt( ttl:, comment: nil ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -2092,11 +2092,11 @@ def get_record( domain_id:, record_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -2132,11 +2132,11 @@ def delete_record( domain_id:, record_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end - if record_id.nil? + if record_id.nil? || record_id == '' raise Appwrite::Exception.new('Missing required parameter: "recordId"') end @@ -2176,7 +2176,7 @@ def update_team( domain_id:, team_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2215,7 +2215,7 @@ def update_team( def get_transfer_status( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2249,7 +2249,7 @@ def get_transfer_status( def get_zone( domain_id: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end @@ -2285,7 +2285,7 @@ def update_zone( domain_id:, content: ) - if domain_id.nil? + if domain_id.nil? || domain_id == '' raise Appwrite::Exception.new('Missing required parameter: "domainId"') end diff --git a/lib/appwrite/services/embeddings.rb b/lib/appwrite/services/embeddings.rb index 3b7003db..e4fb2813 100644 --- a/lib/appwrite/services/embeddings.rb +++ b/lib/appwrite/services/embeddings.rb @@ -19,12 +19,12 @@ def create_text_embeddings( texts:, model: nil ) - api_path = '/embeddings/text' - if texts.nil? raise Appwrite::Exception.new('Missing required parameter: "texts"') end + api_path = '/embeddings/text' + api_params = { texts: texts, model: model, diff --git a/lib/appwrite/services/functions.rb b/lib/appwrite/services/functions.rb index dcf47e0c..2779fcd9 100644 --- a/lib/appwrite/services/functions.rb +++ b/lib/appwrite/services/functions.rb @@ -96,8 +96,6 @@ def create( deployment_retention: nil, interval: nil ) - api_path = '/functions' - if function_id.nil? raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -110,6 +108,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "runtime"') end + api_path = '/functions' + api_params = { functionId: function_id, name: name, @@ -218,13 +218,13 @@ def list_specifications( def get( function_id: ) - api_path = '/functions/{functionId}' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}' + .gsub('{functionId}', function_id) + api_params = {} api_headers = { @@ -266,6 +266,7 @@ def get( # @param [String] runtime_specification Runtime specification for the function executions. # @param [Integer] deployment_retention Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. # @param [Integer] interval Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. + # @param [] email_enabled Enable inbound email triggering for this function. When false or omitted on create, SMTP recipients are rejected. Opt-in; default is off. # # @return [Function] def update( @@ -291,12 +292,10 @@ def update( build_specification: nil, runtime_specification: nil, deployment_retention: nil, - interval: nil + interval: nil, + email_enabled: nil ) - api_path = '/functions/{functionId}' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -304,6 +303,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/functions/{functionId}' + .gsub('{functionId}', function_id) + api_params = { name: name, runtime: runtime, @@ -327,6 +329,7 @@ def update( runtimeSpecification: runtime_specification, deploymentRetention: deployment_retention, interval: interval, + emailEnabled: email_enabled, } api_headers = { @@ -352,18 +355,19 @@ def update( def delete( function_id: ) - api_path = '/functions/{functionId}' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}' + .gsub('{functionId}', function_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -385,10 +389,7 @@ def update_function_deployment( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployment' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -396,6 +397,9 @@ def update_function_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployment' + .gsub('{functionId}', function_id) + api_params = { deploymentId: deployment_id, } @@ -430,13 +434,13 @@ def list_deployments( search: nil, total: nil ) - api_path = '/functions/{functionId}/deployments' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/deployments' + .gsub('{functionId}', function_id) + api_params = { queries: queries, search: search, @@ -483,10 +487,7 @@ def create_deployment( commands: nil, on_progress: nil ) - api_path = '/functions/{functionId}/deployments' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -498,6 +499,9 @@ def create_deployment( raise Appwrite::Exception.new('Missing required parameter: "activate"') end + api_path = '/functions/{functionId}/deployments' + .gsub('{functionId}', function_id) + api_params = { entrypoint: entrypoint, commands: commands, @@ -521,6 +525,7 @@ def create_deployment( param_name: param_name, id_param_name: id_param_name, on_progress: on_progress, + method: 'POST', response_type: Models::Deployment ) end @@ -541,10 +546,7 @@ def create_duplicate_deployment( deployment_id:, build_id: nil ) - api_path = '/functions/{functionId}/deployments/duplicate' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -552,6 +554,9 @@ def create_duplicate_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/duplicate' + .gsub('{functionId}', function_id) + api_params = { deploymentId: deployment_id, buildId: build_id, @@ -596,10 +601,7 @@ def create_template_deployment( reference:, activate: nil ) - api_path = '/functions/{functionId}/deployments/template' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -623,6 +625,9 @@ def create_template_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/functions/{functionId}/deployments/template' + .gsub('{functionId}', function_id) + api_params = { repository: repository, owner: owner, @@ -663,10 +668,7 @@ def create_vcs_deployment( reference:, activate: nil ) - api_path = '/functions/{functionId}/deployments/vcs' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -678,6 +680,9 @@ def create_vcs_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/functions/{functionId}/deployments/vcs' + .gsub('{functionId}', function_id) + api_params = { type: type, reference: reference, @@ -709,18 +714,18 @@ def get_deployment( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployments/{deploymentId}' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -747,23 +752,24 @@ def delete_deployment( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployments/{deploymentId}' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -790,18 +796,18 @@ def get_deployment_download( type: nil, token: nil ) - api_path = '/functions/{functionId}/deployments/{deploymentId}/download' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}/download' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = { type: type, token: token, @@ -834,18 +840,18 @@ def update_deployment_status( function_id:, deployment_id: ) - api_path = '/functions/{functionId}/deployments/{deploymentId}/status' - .gsub('{functionId}', function_id) - .gsub('{deploymentId}', deployment_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/functions/{functionId}/deployments/{deploymentId}/status' + .gsub('{functionId}', function_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -876,13 +882,13 @@ def list_executions( queries: nil, total: nil ) - api_path = '/functions/{functionId}/executions' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/executions' + .gsub('{functionId}', function_id) + api_params = { queries: queries, total: total, @@ -925,13 +931,13 @@ def create_execution( headers: nil, scheduled_at: nil ) - api_path = '/functions/{functionId}/executions' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/executions' + .gsub('{functionId}', function_id) + api_params = { body: body, async: async, @@ -966,18 +972,18 @@ def get_execution( function_id:, execution_id: ) - api_path = '/functions/{functionId}/executions/{executionId}' - .gsub('{functionId}', function_id) - .gsub('{executionId}', execution_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if execution_id.nil? + if execution_id.nil? || execution_id == '' raise Appwrite::Exception.new('Missing required parameter: "executionId"') end + api_path = '/functions/{functionId}/executions/{executionId}' + .gsub('{functionId}', function_id) + .gsub('{executionId}', execution_id) + api_params = {} api_headers = { @@ -1004,23 +1010,24 @@ def delete_execution( function_id:, execution_id: ) - api_path = '/functions/{functionId}/executions/{executionId}' - .gsub('{functionId}', function_id) - .gsub('{executionId}', execution_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if execution_id.nil? + if execution_id.nil? || execution_id == '' raise Appwrite::Exception.new('Missing required parameter: "executionId"') end + api_path = '/functions/{functionId}/executions/{executionId}' + .gsub('{functionId}', function_id) + .gsub('{executionId}', execution_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1043,13 +1050,13 @@ def list_variables( queries: nil, total: nil ) - api_path = '/functions/{functionId}/variables' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/functions/{functionId}/variables' + .gsub('{functionId}', function_id) + api_params = { queries: queries, total: total, @@ -1086,10 +1093,7 @@ def create_variable( value:, secret: nil ) - api_path = '/functions/{functionId}/variables' - .gsub('{functionId}', function_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end @@ -1105,6 +1109,9 @@ def create_variable( raise Appwrite::Exception.new('Missing required parameter: "value"') end + api_path = '/functions/{functionId}/variables' + .gsub('{functionId}', function_id) + api_params = { variableId: variable_id, key: key, @@ -1137,18 +1144,18 @@ def get_variable( function_id:, variable_id: ) - api_path = '/functions/{functionId}/variables/{variableId}' - .gsub('{functionId}', function_id) - .gsub('{variableId}', variable_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/functions/{functionId}/variables/{variableId}' + .gsub('{functionId}', function_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { @@ -1181,18 +1188,18 @@ def update_variable( value: nil, secret: nil ) - api_path = '/functions/{functionId}/variables/{variableId}' - .gsub('{functionId}', function_id) - .gsub('{variableId}', variable_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/functions/{functionId}/variables/{variableId}' + .gsub('{functionId}', function_id) + .gsub('{variableId}', variable_id) + api_params = { key: key, value: value, @@ -1224,23 +1231,24 @@ def delete_variable( function_id:, variable_id: ) - api_path = '/functions/{functionId}/variables/{variableId}' - .gsub('{functionId}', function_id) - .gsub('{variableId}', variable_id) - - if function_id.nil? + if function_id.nil? || function_id == '' raise Appwrite::Exception.new('Missing required parameter: "functionId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/functions/{functionId}/variables/{variableId}' + .gsub('{functionId}', function_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/graphql.rb b/lib/appwrite/services/graphql.rb index 210f528a..7a13b000 100644 --- a/lib/appwrite/services/graphql.rb +++ b/lib/appwrite/services/graphql.rb @@ -14,12 +14,12 @@ def initialize(client) def query( query: ) - api_path = '/graphql' - if query.nil? raise Appwrite::Exception.new('Missing required parameter: "query"') end + api_path = '/graphql' + api_params = { query: query, } @@ -47,12 +47,12 @@ def query( def mutation( query: ) - api_path = '/graphql/mutation' - if query.nil? raise Appwrite::Exception.new('Missing required parameter: "query"') end + api_path = '/graphql/mutation' + api_params = { query: query, } diff --git a/lib/appwrite/services/messaging.rb b/lib/appwrite/services/messaging.rb index ab97d81c..e37e067d 100644 --- a/lib/appwrite/services/messaging.rb +++ b/lib/appwrite/services/messaging.rb @@ -8,7 +8,7 @@ def initialize(client) # Get a list of all messages from the current Appwrite project. # - # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType + # @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: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType, users, targets # @param [String] search Search term to filter your list results. Max length: 256 chars. # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # @@ -74,8 +74,6 @@ def create_email( reply_to_email: nil, reply_to_name: nil ) - api_path = '/messaging/messages/email' - if message_id.nil? raise Appwrite::Exception.new('Missing required parameter: "messageId"') end @@ -88,6 +86,8 @@ def create_email( raise Appwrite::Exception.new('Missing required parameter: "content"') end + api_path = '/messaging/messages/email' + api_params = { messageId: message_id, subject: subject, @@ -157,13 +157,13 @@ def update_email( reply_to_email: nil, reply_to_name: nil ) - api_path = '/messaging/messages/email/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/email/{messageId}' + .gsub('{messageId}', message_id) + api_params = { topics: topics, users: users, @@ -241,12 +241,12 @@ def create_push( priority: nil, channel_id: nil ) - api_path = '/messaging/messages/push' - if message_id.nil? raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/push' + api_params = { messageId: message_id, title: title, @@ -334,13 +334,13 @@ def update_push( priority: nil, channel_id: nil ) - api_path = '/messaging/messages/push/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/push/{messageId}' + .gsub('{messageId}', message_id) + api_params = { topics: topics, users: users, @@ -398,8 +398,6 @@ def create_sms( draft: nil, scheduled_at: nil ) - api_path = '/messaging/messages/sms' - if message_id.nil? raise Appwrite::Exception.new('Missing required parameter: "messageId"') end @@ -408,6 +406,8 @@ def create_sms( raise Appwrite::Exception.new('Missing required parameter: "content"') end + api_path = '/messaging/messages/sms' + api_params = { messageId: message_id, content: content, @@ -456,13 +456,13 @@ def update_sms( draft: nil, scheduled_at: nil ) - api_path = '/messaging/messages/sms/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/sms/{messageId}' + .gsub('{messageId}', message_id) + api_params = { topics: topics, users: users, @@ -496,13 +496,13 @@ def update_sms( def get_message( message_id: ) - api_path = '/messaging/messages/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/{messageId}' + .gsub('{messageId}', message_id) + api_params = {} api_headers = { @@ -528,18 +528,19 @@ def get_message( def delete( message_id: ) - api_path = '/messaging/messages/{messageId}' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/{messageId}' + .gsub('{messageId}', message_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -562,13 +563,13 @@ def list_targets( queries: nil, total: nil ) - api_path = '/messaging/messages/{messageId}/targets' - .gsub('{messageId}', message_id) - - if message_id.nil? + if message_id.nil? || message_id == '' raise Appwrite::Exception.new('Missing required parameter: "messageId"') end + api_path = '/messaging/messages/{messageId}/targets' + .gsub('{messageId}', message_id) + api_params = { queries: queries, total: total, @@ -644,8 +645,6 @@ def create_apns_provider( sandbox: nil, enabled: nil ) - api_path = '/messaging/providers/apns' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -654,6 +653,8 @@ def create_apns_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/apns' + api_params = { providerId: provider_id, name: name, @@ -702,13 +703,13 @@ def update_apns_provider( bundle_id: nil, sandbox: nil ) - api_path = '/messaging/providers/apns/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/apns/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -740,7 +741,7 @@ def update_apns_provider( # @param [String] name Provider name. # @param [] enabled Set as enabled. # @param [Integer] qos Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. # # @return [Provider] def create_appwrite_provider( @@ -789,7 +790,7 @@ def create_appwrite_provider( # @param [String] name Provider name. # @param [] enabled Set as enabled. # @param [Integer] qos Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. - # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. # # @return [Provider] def update_appwrite_provider( @@ -799,7 +800,7 @@ def update_appwrite_provider( qos: nil, expiry: nil ) - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -842,8 +843,6 @@ def create_fcm_provider( service_account_json: nil, enabled: nil ) - api_path = '/messaging/providers/fcm' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -852,6 +851,8 @@ def create_fcm_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/fcm' + api_params = { providerId: provider_id, name: name, @@ -888,13 +889,13 @@ def update_fcm_provider( enabled: nil, service_account_json: nil ) - api_path = '/messaging/providers/fcm/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/fcm/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -942,8 +943,6 @@ def create_mailgun_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/mailgun' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -952,6 +951,8 @@ def create_mailgun_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/mailgun' + api_params = { providerId: provider_id, name: name, @@ -1006,13 +1007,13 @@ def update_mailgun_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/mailgun/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/mailgun/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, apiKey: api_key, @@ -1058,8 +1059,6 @@ def create_msg91_provider( auth_key: nil, enabled: nil ) - api_path = '/messaging/providers/msg91' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1068,6 +1067,8 @@ def create_msg91_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/msg91' + api_params = { providerId: provider_id, name: name, @@ -1110,13 +1111,13 @@ def update_msg91_provider( sender_id: nil, auth_key: nil ) - api_path = '/messaging/providers/msg91/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/msg91/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1162,8 +1163,6 @@ def create_resend_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/resend' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1172,6 +1171,8 @@ def create_resend_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/resend' + api_params = { providerId: provider_id, name: name, @@ -1220,13 +1221,13 @@ def update_resend_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/resend/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/resend/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1274,8 +1275,6 @@ def create_sendgrid_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/sendgrid' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1284,6 +1283,8 @@ def create_sendgrid_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/sendgrid' + api_params = { providerId: provider_id, name: name, @@ -1332,13 +1333,13 @@ def update_sendgrid_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/sendgrid/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/sendgrid/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1390,8 +1391,6 @@ def create_ses_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/ses' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1400,6 +1399,8 @@ def create_ses_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/ses' + api_params = { providerId: provider_id, name: name, @@ -1454,13 +1455,13 @@ def update_ses_provider( reply_to_name: nil, reply_to_email: nil ) - api_path = '/messaging/providers/ses/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/ses/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1522,8 +1523,6 @@ def create_smtp_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/smtp' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1536,6 +1535,8 @@ def create_smtp_provider( raise Appwrite::Exception.new('Missing required parameter: "host"') end + api_path = '/messaging/providers/smtp' + api_params = { providerId: provider_id, name: name, @@ -1602,13 +1603,13 @@ def update_smtp_provider( reply_to_email: nil, enabled: nil ) - api_path = '/messaging/providers/smtp/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/smtp/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, host: host, @@ -1658,8 +1659,6 @@ def create_telesign_provider( api_key: nil, enabled: nil ) - api_path = '/messaging/providers/telesign' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1668,6 +1667,8 @@ def create_telesign_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/telesign' + api_params = { providerId: provider_id, name: name, @@ -1710,13 +1711,13 @@ def update_telesign_provider( api_key: nil, from: nil ) - api_path = '/messaging/providers/telesign/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/telesign/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1758,8 +1759,6 @@ def create_textmagic_provider( api_key: nil, enabled: nil ) - api_path = '/messaging/providers/textmagic' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1768,6 +1767,8 @@ def create_textmagic_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/textmagic' + api_params = { providerId: provider_id, name: name, @@ -1810,13 +1811,13 @@ def update_textmagic_provider( api_key: nil, from: nil ) - api_path = '/messaging/providers/textmagic/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/textmagic/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1844,7 +1845,7 @@ def update_textmagic_provider( # # @param [String] provider_id Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. # @param [String] name Provider name. - # @param [String] from Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + # @param [String] from Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. # @param [String] account_sid Twilio account secret ID. # @param [String] auth_token Twilio authentication token. # @param [] enabled Set as enabled. @@ -1858,8 +1859,6 @@ def create_twilio_provider( auth_token: nil, enabled: nil ) - api_path = '/messaging/providers/twilio' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1868,6 +1867,8 @@ def create_twilio_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/twilio' + api_params = { providerId: provider_id, name: name, @@ -1899,7 +1900,7 @@ def create_twilio_provider( # @param [] enabled Set as enabled. # @param [String] account_sid Twilio account secret ID. # @param [String] auth_token Twilio authentication token. - # @param [String] from Sender number. + # @param [String] from Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. # # @return [Provider] def update_twilio_provider( @@ -1910,13 +1911,13 @@ def update_twilio_provider( auth_token: nil, from: nil ) - api_path = '/messaging/providers/twilio/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/twilio/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -1958,8 +1959,6 @@ def create_vonage_provider( api_secret: nil, enabled: nil ) - api_path = '/messaging/providers/vonage' - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end @@ -1968,6 +1967,8 @@ def create_vonage_provider( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/providers/vonage' + api_params = { providerId: provider_id, name: name, @@ -2010,13 +2011,13 @@ def update_vonage_provider( api_secret: nil, from: nil ) - api_path = '/messaging/providers/vonage/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/vonage/{providerId}' + .gsub('{providerId}', provider_id) + api_params = { name: name, enabled: enabled, @@ -2049,13 +2050,13 @@ def update_vonage_provider( def get_provider( provider_id: ) - api_path = '/messaging/providers/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/{providerId}' + .gsub('{providerId}', provider_id) + api_params = {} api_headers = { @@ -2080,18 +2081,19 @@ def get_provider( def delete_provider( provider_id: ) - api_path = '/messaging/providers/{providerId}' - .gsub('{providerId}', provider_id) - - if provider_id.nil? + if provider_id.nil? || provider_id == '' raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/messaging/providers/{providerId}' + .gsub('{providerId}', provider_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -2142,7 +2144,7 @@ def list_topics( # @param [String] name Topic Name. # @param [Array] subscribe An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. # @param [Integer] qos MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. # # @return [Topic] def create_topic( @@ -2152,8 +2154,6 @@ def create_topic( qos: nil, expiry: nil ) - api_path = '/messaging/topics' - if topic_id.nil? raise Appwrite::Exception.new('Missing required parameter: "topicId"') end @@ -2162,6 +2162,8 @@ def create_topic( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/topics' + api_params = { topicId: topic_id, name: name, @@ -2194,13 +2196,13 @@ def create_topic( def get_topic( topic_id: ) - api_path = '/messaging/topics/{topicId}' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}' + .gsub('{topicId}', topic_id) + api_params = {} api_headers = { @@ -2224,7 +2226,7 @@ def get_topic( # @param [String] name Topic Name. # @param [Array] subscribe An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. # @param [Integer] qos MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. - # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). + # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. # # @return [Topic] def update_topic( @@ -2234,13 +2236,13 @@ def update_topic( qos: nil, expiry: nil ) - api_path = '/messaging/topics/{topicId}' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}' + .gsub('{topicId}', topic_id) + api_params = { name: name, subscribe: subscribe, @@ -2271,18 +2273,19 @@ def update_topic( def delete_topic( topic_id: ) - api_path = '/messaging/topics/{topicId}' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}' + .gsub('{topicId}', topic_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -2307,13 +2310,13 @@ def list_subscribers( search: nil, total: nil ) - api_path = '/messaging/topics/{topicId}/subscribers' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end + api_path = '/messaging/topics/{topicId}/subscribers' + .gsub('{topicId}', topic_id) + api_params = { queries: queries, search: search, @@ -2346,10 +2349,7 @@ def create_subscriber( subscriber_id:, target_id: ) - api_path = '/messaging/topics/{topicId}/subscribers' - .gsub('{topicId}', topic_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end @@ -2361,6 +2361,9 @@ def create_subscriber( raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/messaging/topics/{topicId}/subscribers' + .gsub('{topicId}', topic_id) + api_params = { subscriberId: subscriber_id, targetId: target_id, @@ -2392,18 +2395,18 @@ def get_subscriber( topic_id:, subscriber_id: ) - api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' - .gsub('{topicId}', topic_id) - .gsub('{subscriberId}', subscriber_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end - if subscriber_id.nil? + if subscriber_id.nil? || subscriber_id == '' raise Appwrite::Exception.new('Missing required parameter: "subscriberId"') end + api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .gsub('{topicId}', topic_id) + .gsub('{subscriberId}', subscriber_id) + api_params = {} api_headers = { @@ -2430,23 +2433,24 @@ def delete_subscriber( topic_id:, subscriber_id: ) - api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' - .gsub('{topicId}', topic_id) - .gsub('{subscriberId}', subscriber_id) - - if topic_id.nil? + if topic_id.nil? || topic_id == '' raise Appwrite::Exception.new('Missing required parameter: "topicId"') end - if subscriber_id.nil? + if subscriber_id.nil? || subscriber_id == '' raise Appwrite::Exception.new('Missing required parameter: "subscriberId"') end + api_path = '/messaging/topics/{topicId}/subscribers/{subscriberId}' + .gsub('{topicId}', topic_id) + .gsub('{subscriberId}', subscriber_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/mongo.rb b/lib/appwrite/services/mongo.rb index 0c95972a..7c968604 100644 --- a/lib/appwrite/services/mongo.rb +++ b/lib/appwrite/services/mongo.rb @@ -50,7 +50,7 @@ def list( # @param [Integer] pitr_retention_days Number of days to retain PITR data. # @param [] storage_autoscaling Enable automatic storage expansion when usage exceeds threshold. # @param [Integer] storage_autoscaling_threshold_percent Storage usage percentage (50-95) that triggers automatic expansion. - # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. 0 means no limit. + # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. # # @return [DedicatedDatabase] def create( @@ -69,8 +69,6 @@ def create( storage_autoscaling_threshold_percent: nil, storage_autoscaling_max_gb: nil ) - api_path = '/mongo' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -79,6 +77,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/mongo' + api_params = { databaseId: database_id, name: name, @@ -112,8 +112,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -145,13 +145,13 @@ def list_specifications() def get( database_id: ) - api_path = '/mongo/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update( sql_api_max_bytes: nil, sql_api_timeout_seconds: nil ) - api_path = '/mongo/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, status: status, @@ -275,13 +275,13 @@ def update( def delete( database_id: ) - api_path = '/mongo/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -309,13 +309,13 @@ def list_backups( database_id:, queries: nil ) - api_path = '/mongo/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -345,13 +345,13 @@ def create_backup( database_id:, type: nil ) - api_path = '/mongo/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { type: type, } @@ -381,13 +381,13 @@ def list_backup_policies( database_id:, queries: nil ) - api_path = '/mongo/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -426,10 +426,7 @@ def create_backup_policy( type: nil, enabled: nil ) - api_path = '/mongo/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -449,6 +446,9 @@ def create_backup_policy( raise Appwrite::Exception.new('Missing required parameter: "retention"') end + api_path = '/mongo/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { policyId: policy_id, name: name, @@ -483,18 +483,18 @@ def get_backup_policy( database_id:, policy_id: ) - api_path = '/mongo/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mongo/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -529,18 +529,18 @@ def update_backup_policy( retention: nil, enabled: nil ) - api_path = '/mongo/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mongo/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = { name: name, schedule: schedule, @@ -574,18 +574,18 @@ def delete_backup_policy( database_id:, policy_id: ) - api_path = '/mongo/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mongo/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -626,10 +626,7 @@ def update_backup_storage( prefix: nil, endpoint: nil ) - api_path = '/mongo/{databaseId}/backups/storage' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -649,6 +646,9 @@ def update_backup_storage( raise Appwrite::Exception.new('Missing required parameter: "secretKey"') end + api_path = '/mongo/{databaseId}/backups/storage' + .gsub('{databaseId}', database_id) + api_params = { provider: provider, bucket: bucket, @@ -685,18 +685,18 @@ def get_backup( database_id:, backup_id: ) - api_path = '/mongo/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mongo/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -724,18 +724,18 @@ def delete_backup( database_id:, backup_id: ) - api_path = '/mongo/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mongo/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -761,13 +761,13 @@ def delete_backup( def list_branches( database_id: ) - api_path = '/mongo/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -800,13 +800,13 @@ def create_branch( branch_id: nil, ttl: nil ) - api_path = '/mongo/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = { branchId: branch_id, ttl: ttl, @@ -839,18 +839,18 @@ def delete_branch( database_id:, branch_id: ) - api_path = '/mongo/{databaseId}/branches/{branchId}' - .gsub('{databaseId}', database_id) - .gsub('{branchId}', branch_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if branch_id.nil? + if branch_id.nil? || branch_id == '' raise Appwrite::Exception.new('Missing required parameter: "branchId"') end + api_path = '/mongo/{databaseId}/branches/{branchId}' + .gsub('{databaseId}', database_id) + .gsub('{branchId}', branch_id) + api_params = {} api_headers = { @@ -879,13 +879,13 @@ def delete_branch( def update_credentials( database_id: ) - api_path = '/mongo/{databaseId}/credentials' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/credentials' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -921,13 +921,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/mongo/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -961,10 +961,7 @@ def update_maintenance( day:, hour_utc: ) - api_path = '/mongo/{databaseId}/maintenance' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -976,6 +973,9 @@ def update_maintenance( raise Appwrite::Exception.new('Missing required parameter: "hourUtc"') end + api_path = '/mongo/{databaseId}/maintenance' + .gsub('{databaseId}', database_id) + api_params = { day: day, hourUtc: hour_utc, @@ -1011,10 +1011,7 @@ def create_migration( target_type:, specification: nil ) - api_path = '/mongo/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1022,6 +1019,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "targetType"') end + api_path = '/mongo/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { targetType: target_type, specification: specification, @@ -1059,13 +1059,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/mongo/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1095,13 +1095,13 @@ def list_operations( def get_pitr( database_id: ) - api_path = '/mongo/{databaseId}/pitr' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/pitr' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1127,13 +1127,13 @@ def get_pitr( def get_replicas( database_id: ) - api_path = '/mongo/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1167,13 +1167,13 @@ def list_restorations( limit: nil, offset: nil ) - api_path = '/mongo/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { status: status, type: type, @@ -1200,11 +1200,25 @@ def list_restorations( # an ISO 8601 datetime. PITR requires the database to have PITR enabled and # is only available for enterprise databases. # + # By default the backup is replayed over the database it was taken from. Pass + # `restoreMode` as `clone` to recover it onto a second workload beside this + # database instead: this database keeps serving its own data while the clone + # is filled, and the switch happens as soon as the clone is ready, on the + # endpoint and credentials it already had. Pass `autoPromote` as false to + # hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + # to recover onto a separate database with its own endpoint, either one you + # name with `targetDatabaseId` or one provisioned as a copy of this + # database's engine, version, specification and replicas. Neither mode is + # available for a point-in-time recovery or an incremental backup. + # # @param [String] database_id Database ID. # @param [String] type Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. # @param [String] backup_id Backup ID to restore from (required for backup type). - # @param [String] target_database_id Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + # @param [String] target_database_id Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. # @param [String] target_time Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. + # @param [String] restore_mode Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + # @param [String] target_name Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + # @param [] auto_promote Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. # # @return [DedicatedDatabaseRestoration] def create_restoration( @@ -1212,20 +1226,26 @@ def create_restoration( type: nil, backup_id: nil, target_database_id: nil, - target_time: nil + target_time: nil, + restore_mode: nil, + target_name: nil, + auto_promote: nil ) - api_path = '/mongo/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { type: type, backupId: backup_id, targetDatabaseId: target_database_id, targetTime: target_time, + restoreMode: restore_mode, + targetName: target_name, + autoPromote: auto_promote, } api_headers = { @@ -1254,27 +1274,71 @@ def get_restoration( database_id:, restoration_id: ) + if database_id.nil? || database_id == '' + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if restoration_id.nil? || restoration_id == '' + raise Appwrite::Exception.new('Missing required parameter: "restorationId"') + end + api_path = '/mongo/{databaseId}/restorations/{restorationId}' .gsub('{databaseId}', database_id) .gsub('{restorationId}', restoration_id) - if database_id.nil? + 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::DedicatedDatabaseRestoration + ) + end + + # Switch the database over to the clone a restoration recovered. The database + # keeps + # its endpoint and credentials; clients reconnect once. Writes made after the + # recovery point are discarded, and the side being replaced is retained + # briefly so + # the switch can be reversed. + # + # @param [String] database_id Database ID. + # @param [String] restoration_id Restoration ID. + # + # @return [DedicatedDatabaseRestoration] + def promote_restoration( + database_id:, + restoration_id: + ) + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/mongo/{databaseId}/restorations/{restorationId}/promotions' + .gsub('{databaseId}', database_id) + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', "accept": 'application/json', } @client.call( - method: 'GET', + method: 'POST', path: api_path, headers: api_headers, params: api_params, @@ -1292,13 +1356,13 @@ def get_restoration( def get_status( database_id: ) - api_path = '/mongo/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mongo/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1326,10 +1390,7 @@ def create_upgrade( database_id:, target_version: ) - api_path = '/mongo/{databaseId}/upgrades' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1337,6 +1398,9 @@ def create_upgrade( raise Appwrite::Exception.new('Missing required parameter: "targetVersion"') end + api_path = '/mongo/{databaseId}/upgrades' + .gsub('{databaseId}', database_id) + api_params = { targetVersion: target_version, } diff --git a/lib/appwrite/services/mysql.rb b/lib/appwrite/services/mysql.rb index 2e21c83c..d7bdca2b 100644 --- a/lib/appwrite/services/mysql.rb +++ b/lib/appwrite/services/mysql.rb @@ -50,7 +50,7 @@ def list( # @param [Integer] pitr_retention_days Number of days to retain PITR data. # @param [] storage_autoscaling Enable automatic storage expansion when usage exceeds threshold. # @param [Integer] storage_autoscaling_threshold_percent Storage usage percentage (50-95) that triggers automatic expansion. - # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. 0 means no limit. + # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. # # @return [DedicatedDatabase] def create( @@ -69,8 +69,6 @@ def create( storage_autoscaling_threshold_percent: nil, storage_autoscaling_max_gb: nil ) - api_path = '/mysql' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -79,6 +77,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/mysql' + api_params = { databaseId: database_id, name: name, @@ -112,8 +112,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -145,13 +145,13 @@ def list_specifications() def get( database_id: ) - api_path = '/mysql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update( sql_api_max_bytes: nil, sql_api_timeout_seconds: nil ) - api_path = '/mysql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, status: status, @@ -275,13 +275,13 @@ def update( def delete( database_id: ) - api_path = '/mysql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -309,13 +309,13 @@ def list_backups( database_id:, queries: nil ) - api_path = '/mysql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -345,13 +345,13 @@ def create_backup( database_id:, type: nil ) - api_path = '/mysql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { type: type, } @@ -381,13 +381,13 @@ def list_backup_policies( database_id:, queries: nil ) - api_path = '/mysql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -426,10 +426,7 @@ def create_backup_policy( type: nil, enabled: nil ) - api_path = '/mysql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -449,6 +446,9 @@ def create_backup_policy( raise Appwrite::Exception.new('Missing required parameter: "retention"') end + api_path = '/mysql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { policyId: policy_id, name: name, @@ -483,18 +483,18 @@ def get_backup_policy( database_id:, policy_id: ) - api_path = '/mysql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mysql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -529,18 +529,18 @@ def update_backup_policy( retention: nil, enabled: nil ) - api_path = '/mysql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mysql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = { name: name, schedule: schedule, @@ -574,18 +574,18 @@ def delete_backup_policy( database_id:, policy_id: ) - api_path = '/mysql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/mysql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -626,10 +626,7 @@ def update_backup_storage( prefix: nil, endpoint: nil ) - api_path = '/mysql/{databaseId}/backups/storage' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -649,6 +646,9 @@ def update_backup_storage( raise Appwrite::Exception.new('Missing required parameter: "secretKey"') end + api_path = '/mysql/{databaseId}/backups/storage' + .gsub('{databaseId}', database_id) + api_params = { provider: provider, bucket: bucket, @@ -685,18 +685,18 @@ def get_backup( database_id:, backup_id: ) - api_path = '/mysql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mysql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -724,18 +724,18 @@ def delete_backup( database_id:, backup_id: ) - api_path = '/mysql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/mysql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -761,13 +761,13 @@ def delete_backup( def list_branches( database_id: ) - api_path = '/mysql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -800,13 +800,13 @@ def create_branch( branch_id: nil, ttl: nil ) - api_path = '/mysql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = { branchId: branch_id, ttl: ttl, @@ -839,18 +839,18 @@ def delete_branch( database_id:, branch_id: ) - api_path = '/mysql/{databaseId}/branches/{branchId}' - .gsub('{databaseId}', database_id) - .gsub('{branchId}', branch_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if branch_id.nil? + if branch_id.nil? || branch_id == '' raise Appwrite::Exception.new('Missing required parameter: "branchId"') end + api_path = '/mysql/{databaseId}/branches/{branchId}' + .gsub('{databaseId}', database_id) + .gsub('{branchId}', branch_id) + api_params = {} api_headers = { @@ -879,13 +879,13 @@ def delete_branch( def update_credentials( database_id: ) - api_path = '/mysql/{databaseId}/credentials' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/credentials' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -912,11 +912,15 @@ def update_credentials( # without a per-query cloud round-trip. The statement type must be on the # database's configured allow-list. Use bound parameters for any # user-supplied values — the API does not interpolate raw strings. + # Long-running statements (for example CREATE INDEX) can outlive the HTTP + # request: if the request ends before a result is returned, check the + # database before retrying, and prefer a direct connection for work that may + # take minutes. # # @param [String] database_id Database ID. # @param [String] sql SQL statement to execute. Exactly one statement per request. # @param [Hash] bindings Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. - # @param [Integer] timeout_seconds Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. + # @param [Integer] timeout_seconds Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. # # @return [DedicatedDatabaseExecution] def create_execution( @@ -925,10 +929,7 @@ def create_execution( bindings: nil, timeout_seconds: nil ) - api_path = '/mysql/{databaseId}/executions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -936,6 +937,9 @@ def create_execution( raise Appwrite::Exception.new('Missing required parameter: "sql"') end + api_path = '/mysql/{databaseId}/executions' + .gsub('{databaseId}', database_id) + api_params = { sql: sql, bindings: bindings, @@ -975,13 +979,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/mysql/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1015,10 +1019,7 @@ def update_maintenance( day:, hour_utc: ) - api_path = '/mysql/{databaseId}/maintenance' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1030,6 +1031,9 @@ def update_maintenance( raise Appwrite::Exception.new('Missing required parameter: "hourUtc"') end + api_path = '/mysql/{databaseId}/maintenance' + .gsub('{databaseId}', database_id) + api_params = { day: day, hourUtc: hour_utc, @@ -1065,10 +1069,7 @@ def create_migration( target_type:, specification: nil ) - api_path = '/mysql/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1076,6 +1077,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "targetType"') end + api_path = '/mysql/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { targetType: target_type, specification: specification, @@ -1113,13 +1117,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/mysql/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1149,13 +1153,13 @@ def list_operations( def get_pitr( database_id: ) - api_path = '/mysql/{databaseId}/pitr' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/pitr' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1181,13 +1185,13 @@ def get_pitr( def get_pooler( database_id: ) - api_path = '/mysql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1211,7 +1215,7 @@ def get_pooler( # @param [String] mode Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. # @param [Integer] max_connections Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. # @param [Integer] default_pool_size Default pool size per user. - # @param [] read_write_splitting Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + # @param [] read_write_splitting Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. # @param [String] pooler_cpu_request Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). # @param [String] pooler_cpu_limit Pooler sidecar CPU limit override (Kubernetes quantity, e.g. "500m" or "1"). Leave null for the proportional default (10% of DB CPU, floor 200m). Changing this field rolls the database pod. # @param [String] pooler_memory_request Pooler sidecar memory request override (Kubernetes quantity, e.g. "128Mi" or "1Gi"). Leave null for the proportional default (7.5% of DB memory, floor 64Mi). @@ -1229,13 +1233,13 @@ def update_pooler( pooler_memory_request: nil, pooler_memory_limit: nil ) - api_path = '/mysql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = { mode: mode, maxConnections: max_connections, @@ -1271,13 +1275,13 @@ def update_pooler( def get_replicas( database_id: ) - api_path = '/mysql/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1311,13 +1315,13 @@ def list_restorations( limit: nil, offset: nil ) - api_path = '/mysql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { status: status, type: type, @@ -1344,11 +1348,25 @@ def list_restorations( # an ISO 8601 datetime. PITR requires the database to have PITR enabled and # is only available for enterprise databases. # + # By default the backup is replayed over the database it was taken from. Pass + # `restoreMode` as `clone` to recover it onto a second workload beside this + # database instead: this database keeps serving its own data while the clone + # is filled, and the switch happens as soon as the clone is ready, on the + # endpoint and credentials it already had. Pass `autoPromote` as false to + # hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + # to recover onto a separate database with its own endpoint, either one you + # name with `targetDatabaseId` or one provisioned as a copy of this + # database's engine, version, specification and replicas. Neither mode is + # available for a point-in-time recovery or an incremental backup. + # # @param [String] database_id Database ID. # @param [String] type Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. # @param [String] backup_id Backup ID to restore from (required for backup type). - # @param [String] target_database_id Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + # @param [String] target_database_id Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. # @param [String] target_time Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. + # @param [String] restore_mode Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + # @param [String] target_name Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + # @param [] auto_promote Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. # # @return [DedicatedDatabaseRestoration] def create_restoration( @@ -1356,20 +1374,26 @@ def create_restoration( type: nil, backup_id: nil, target_database_id: nil, - target_time: nil + target_time: nil, + restore_mode: nil, + target_name: nil, + auto_promote: nil ) - api_path = '/mysql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { type: type, backupId: backup_id, targetDatabaseId: target_database_id, targetTime: target_time, + restoreMode: restore_mode, + targetName: target_name, + autoPromote: auto_promote, } api_headers = { @@ -1398,27 +1422,71 @@ def get_restoration( database_id:, restoration_id: ) + if database_id.nil? || database_id == '' + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if restoration_id.nil? || restoration_id == '' + raise Appwrite::Exception.new('Missing required parameter: "restorationId"') + end + api_path = '/mysql/{databaseId}/restorations/{restorationId}' .gsub('{databaseId}', database_id) .gsub('{restorationId}', restoration_id) - if database_id.nil? + 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::DedicatedDatabaseRestoration + ) + end + + # Switch the database over to the clone a restoration recovered. The database + # keeps + # its endpoint and credentials; clients reconnect once. Writes made after the + # recovery point are discarded, and the side being replaced is retained + # briefly so + # the switch can be reversed. + # + # @param [String] database_id Database ID. + # @param [String] restoration_id Restoration ID. + # + # @return [DedicatedDatabaseRestoration] + def promote_restoration( + database_id:, + restoration_id: + ) + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/mysql/{databaseId}/restorations/{restorationId}/promotions' + .gsub('{databaseId}', database_id) + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', "accept": 'application/json', } @client.call( - method: 'GET', + method: 'POST', path: api_path, headers: api_headers, params: api_params, @@ -1436,13 +1504,13 @@ def get_restoration( def get_status( database_id: ) - api_path = '/mysql/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/mysql/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1470,10 +1538,7 @@ def create_upgrade( database_id:, target_version: ) - api_path = '/mysql/{databaseId}/upgrades' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1481,6 +1546,9 @@ def create_upgrade( raise Appwrite::Exception.new('Missing required parameter: "targetVersion"') end + api_path = '/mysql/{databaseId}/upgrades' + .gsub('{databaseId}', database_id) + api_params = { targetVersion: target_version, } diff --git a/lib/appwrite/services/oauth2.rb b/lib/appwrite/services/oauth2.rb index 33402a28..0571d694 100644 --- a/lib/appwrite/services/oauth2.rb +++ b/lib/appwrite/services/oauth2.rb @@ -22,13 +22,13 @@ def approve( 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_path = '/oauth2/{project_id}/approve' + .gsub('{project_id}', @client.get_config('project')) + api_params = { grant_id: grant_id, authorization_details: authorization_details, @@ -66,7 +66,7 @@ def approve( # @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 [Array] 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. # @@ -137,7 +137,7 @@ def authorize( # @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 [Array] 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. # @@ -198,7 +198,7 @@ def authorize_post( # @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 [Array] 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] @@ -245,13 +245,13 @@ def create_device_authorization( 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_path = '/oauth2/{project_id}/grants' + .gsub('{project_id}', @client.get_config('project')) + api_params = { user_code: user_code, } @@ -280,14 +280,14 @@ def create_grant( def get_grant( grant_id: ) + if grant_id.nil? || grant_id == '' + raise Appwrite::Exception.new('Missing required parameter: "grantId"') + end + 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 = { @@ -398,7 +398,7 @@ def list_organizations( # @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 [Array] 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] @@ -417,9 +417,6 @@ def create_par( 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 @@ -432,6 +429,9 @@ def create_par( raise Appwrite::Exception.new('Missing required parameter: "responseType"') end + api_path = '/oauth2/{project_id}/par' + .gsub('{project_id}', @client.get_config('project')) + api_params = { client_id: client_id, redirect_uri: redirect_uri, @@ -509,13 +509,13 @@ def list_projects( 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_path = '/oauth2/{project_id}/reject' + .gsub('{project_id}', @client.get_config('project')) + api_params = { grant_id: grant_id, } @@ -548,13 +548,13 @@ def revoke( 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_path = '/oauth2/{project_id}/revoke' + .gsub('{project_id}', @client.get_config('project')) + api_params = { token: token, token_type_hint: token_type_hint, @@ -586,7 +586,7 @@ def revoke( # @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 [Array] 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] @@ -602,13 +602,13 @@ def create_token( 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_path = '/oauth2/{project_id}/token' + .gsub('{project_id}', @client.get_config('project')) + api_params = { grant_type: grant_type, code: code, diff --git a/lib/appwrite/services/organization.rb b/lib/appwrite/services/organization.rb index b43b8f29..e086c703 100644 --- a/lib/appwrite/services/organization.rb +++ b/lib/appwrite/services/organization.rb @@ -37,12 +37,12 @@ def get() def update( name: ) - api_path = '/organization' - if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/organization' + api_params = { name: name, } @@ -75,6 +75,7 @@ def delete() api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -129,12 +130,12 @@ 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_path = '/organization/installations' + api_params = { appId: app_id, authorizationDetails: authorization_details, @@ -164,13 +165,13 @@ def create_installation( def get_installation( installation_id: ) - api_path = '/organization/installations/{installationId}' - .gsub('{installationId}', installation_id) - - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -200,13 +201,13 @@ def update_installation( installation_id:, authorization_details: nil ) - api_path = '/organization/installations/{installationId}' - .gsub('{installationId}', installation_id) - - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) + api_params = { authorizationDetails: authorization_details, } @@ -236,216 +237,21 @@ def update_installation( def delete_installation( installation_id: ) - api_path = '/organization/installations/{installationId}' - .gsub('{installationId}', installation_id) - - if installation_id.nil? + if installation_id.nil? || installation_id == '' 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 - # @param [] total When set to false, the total count returned will be 0 and will not be calculated. - # - # @return [KeyList] - def list_keys( - queries: nil, - total: nil - ) - api_path = '/organization/keys' - - api_params = { - queries: queries, - total: total, - } - - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), - "accept": 'application/json', - } - - @client.call( - method: 'GET', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::KeyList - ) - end - - # Create a new organization API key. - # - # @param [String] key_id Key ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - # @param [String] name Key name. Max length: 128 chars. - # @param [Array] scopes Key scopes list. Maximum of 200 scopes are allowed. - # @param [String] expire Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - # - # @return [Key] - def create_key( - key_id:, - name:, - scopes:, - expire: nil - ) - api_path = '/organization/keys' - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') - end - - if name.nil? - raise Appwrite::Exception.new('Missing required parameter: "name"') - end - - if scopes.nil? - raise Appwrite::Exception.new('Missing required parameter: "scopes"') - end - - api_params = { - keyId: key_id, - name: name, - scopes: scopes, - expire: expire, - } - - api_headers = { - "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::Key - ) - end - - # Get a key by its unique ID. This endpoint returns details about a specific - # API key in your organization including its scopes. - # - # @param [String] key_id Key unique ID. - # - # @return [Key] - def get_key( - key_id: - ) - api_path = '/organization/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') - end + api_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) api_params = {} - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), - "accept": 'application/json', - } - - @client.call( - method: 'GET', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::Key - ) - end - - # Update a key by its unique ID. Use this endpoint to update the name, - # scopes, or expiration time of an API key. - # - # @param [String] key_id Key unique ID. - # @param [String] name Key name. Max length: 128 chars. - # @param [Array] scopes Key scopes list. Maximum of 200 scopes are allowed. - # @param [String] expire Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. - # - # @return [Key] - def update_key( - key_id:, - name:, - scopes:, - expire: nil - ) - api_path = '/organization/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') - end - - if name.nil? - raise Appwrite::Exception.new('Missing required parameter: "name"') - end - - if scopes.nil? - raise Appwrite::Exception.new('Missing required parameter: "scopes"') - end - - api_params = { - name: name, - scopes: scopes, - expire: expire, - } - api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', "accept": 'application/json', } - @client.call( - method: 'PUT', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::Key - ) - end - - # Delete a key by its unique ID. Once deleted, the key can no longer be used - # to authenticate API calls. - # - # @param [String] key_id Key unique ID. - # - # @return [] - def delete_key( - key_id: - ) - api_path = '/organization/keys/{keyId}' - .gsub('{keyId}', key_id) - - 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', - } - @client.call( method: 'DELETE', path: api_path, @@ -508,12 +314,12 @@ def create_membership( url: nil, name: nil ) - api_path = '/organization/memberships' - if roles.nil? raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/organization/memberships' + api_params = { email: email, userId: user_id, @@ -546,13 +352,13 @@ def create_membership( def get_membership( membership_id: ) - api_path = '/organization/memberships/{membershipId}' - .gsub('{membershipId}', membership_id) - - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/organization/memberships/{membershipId}' + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { @@ -579,10 +385,7 @@ def update_membership( membership_id:, roles: ) - api_path = '/organization/memberships/{membershipId}' - .gsub('{membershipId}', membership_id) - - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end @@ -590,6 +393,9 @@ def update_membership( raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/organization/memberships/{membershipId}' + .gsub('{membershipId}', membership_id) + api_params = { roles: roles, } @@ -619,18 +425,19 @@ def update_membership( def delete_membership( membership_id: ) - api_path = '/organization/memberships/{membershipId}' - .gsub('{membershipId}', membership_id) - - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/organization/memberships/{membershipId}' + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -688,8 +495,6 @@ def create_project( name:, region: nil ) - api_path = '/organization/projects' - if project_id.nil? raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -698,6 +503,8 @@ def create_project( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/organization/projects' + api_params = { projectId: project_id, name: name, @@ -727,17 +534,18 @@ def create_project( def get_project( project_id: ) - api_path = '/organization/projects/{projectId}' - .gsub('{projectId}', project_id) - - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end + api_path = '/organization/projects/{projectId}' + .gsub('{projectId}', project_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', } @client.call( @@ -759,10 +567,7 @@ def update_project( project_id:, name: ) - api_path = '/organization/projects/{projectId}' - .gsub('{projectId}', project_id) - - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -770,6 +575,9 @@ def update_project( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/organization/projects/{projectId}' + .gsub('{projectId}', project_id) + api_params = { name: name, } @@ -797,18 +605,19 @@ def update_project( def delete_project( project_id: ) - api_path = '/organization/projects/{projectId}' - .gsub('{projectId}', project_id) - - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end + api_path = '/organization/projects/{projectId}' + .gsub('{projectId}', project_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -831,7 +640,7 @@ def list_project_keys( queries: nil, total: nil ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -874,7 +683,7 @@ def create_ephemeral_project_key( scopes:, duration: ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end @@ -919,11 +728,11 @@ def get_project_key( project_id:, key_id: ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end @@ -964,11 +773,11 @@ def update_project_key( scopes:, expire: nil ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end @@ -1016,11 +825,11 @@ def delete_project_key( project_id:, key_id: ) - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end diff --git a/lib/appwrite/services/postgresql.rb b/lib/appwrite/services/postgresql.rb index cd67e74e..24c0ce2d 100644 --- a/lib/appwrite/services/postgresql.rb +++ b/lib/appwrite/services/postgresql.rb @@ -50,7 +50,7 @@ def list( # @param [Integer] pitr_retention_days Number of days to retain PITR data. # @param [] storage_autoscaling Enable automatic storage expansion when usage exceeds threshold. # @param [Integer] storage_autoscaling_threshold_percent Storage usage percentage (50-95) that triggers automatic expansion. - # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. 0 means no limit. + # @param [Integer] storage_autoscaling_max_gb Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. # # @return [DedicatedDatabase] def create( @@ -69,8 +69,6 @@ def create( storage_autoscaling_threshold_percent: nil, storage_autoscaling_max_gb: nil ) - api_path = '/postgresql' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -79,6 +77,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/postgresql' + api_params = { databaseId: database_id, name: name, @@ -112,8 +112,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -145,13 +145,13 @@ def list_specifications() def get( database_id: ) - api_path = '/postgresql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update( sql_api_max_bytes: nil, sql_api_timeout_seconds: nil ) - api_path = '/postgresql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, status: status, @@ -275,13 +275,13 @@ def update( def delete( database_id: ) - api_path = '/postgresql/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -309,13 +309,13 @@ def list_backups( database_id:, queries: nil ) - api_path = '/postgresql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -345,13 +345,13 @@ def create_backup( database_id:, type: nil ) - api_path = '/postgresql/{databaseId}/backups' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/backups' + .gsub('{databaseId}', database_id) + api_params = { type: type, } @@ -381,13 +381,13 @@ def list_backup_policies( database_id:, queries: nil ) - api_path = '/postgresql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, } @@ -426,10 +426,7 @@ def create_backup_policy( type: nil, enabled: nil ) - api_path = '/postgresql/{databaseId}/backups/policies' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -449,6 +446,9 @@ def create_backup_policy( raise Appwrite::Exception.new('Missing required parameter: "retention"') end + api_path = '/postgresql/{databaseId}/backups/policies' + .gsub('{databaseId}', database_id) + api_params = { policyId: policy_id, name: name, @@ -483,18 +483,18 @@ def get_backup_policy( database_id:, policy_id: ) - api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -529,18 +529,18 @@ def update_backup_policy( retention: nil, enabled: nil ) - api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = { name: name, schedule: schedule, @@ -574,18 +574,18 @@ def delete_backup_policy( database_id:, policy_id: ) - api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' - .gsub('{databaseId}', database_id) - .gsub('{policyId}', policy_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if policy_id.nil? + if policy_id.nil? || policy_id == '' raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/postgresql/{databaseId}/backups/policies/{policyId}' + .gsub('{databaseId}', database_id) + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -626,10 +626,7 @@ def update_backup_storage( prefix: nil, endpoint: nil ) - api_path = '/postgresql/{databaseId}/backups/storage' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -649,6 +646,9 @@ def update_backup_storage( raise Appwrite::Exception.new('Missing required parameter: "secretKey"') end + api_path = '/postgresql/{databaseId}/backups/storage' + .gsub('{databaseId}', database_id) + api_params = { provider: provider, bucket: bucket, @@ -685,18 +685,18 @@ def get_backup( database_id:, backup_id: ) - api_path = '/postgresql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/postgresql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -724,18 +724,18 @@ def delete_backup( database_id:, backup_id: ) - api_path = '/postgresql/{databaseId}/backups/{backupId}' - .gsub('{databaseId}', database_id) - .gsub('{backupId}', backup_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if backup_id.nil? + if backup_id.nil? || backup_id == '' raise Appwrite::Exception.new('Missing required parameter: "backupId"') end + api_path = '/postgresql/{databaseId}/backups/{backupId}' + .gsub('{databaseId}', database_id) + .gsub('{backupId}', backup_id) + api_params = {} api_headers = { @@ -761,13 +761,13 @@ def delete_backup( def list_branches( database_id: ) - api_path = '/postgresql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -800,13 +800,13 @@ def create_branch( branch_id: nil, ttl: nil ) - api_path = '/postgresql/{databaseId}/branches' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/branches' + .gsub('{databaseId}', database_id) + api_params = { branchId: branch_id, ttl: ttl, @@ -839,18 +839,18 @@ def delete_branch( database_id:, branch_id: ) - api_path = '/postgresql/{databaseId}/branches/{branchId}' - .gsub('{databaseId}', database_id) - .gsub('{branchId}', branch_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if branch_id.nil? + if branch_id.nil? || branch_id == '' raise Appwrite::Exception.new('Missing required parameter: "branchId"') end + api_path = '/postgresql/{databaseId}/branches/{branchId}' + .gsub('{databaseId}', database_id) + .gsub('{branchId}', branch_id) + api_params = {} api_headers = { @@ -879,13 +879,13 @@ def delete_branch( def update_credentials( database_id: ) - api_path = '/postgresql/{databaseId}/credentials' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/credentials' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -912,11 +912,15 @@ def update_credentials( # without a per-query cloud round-trip. The statement type must be on the # database's configured allow-list. Use bound parameters for any # user-supplied values — the API does not interpolate raw strings. + # Long-running statements (for example CREATE INDEX) can outlive the HTTP + # request: if the request ends before a result is returned, check the + # database before retrying, and prefer a direct connection for work that may + # take minutes. # # @param [String] database_id Database ID. # @param [String] sql SQL statement to execute. Exactly one statement per request. # @param [Hash] bindings Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. - # @param [Integer] timeout_seconds Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. + # @param [Integer] timeout_seconds Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. # # @return [DedicatedDatabaseExecution] def create_execution( @@ -925,10 +929,7 @@ def create_execution( bindings: nil, timeout_seconds: nil ) - api_path = '/postgresql/{databaseId}/executions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -936,6 +937,9 @@ def create_execution( raise Appwrite::Exception.new('Missing required parameter: "sql"') end + api_path = '/postgresql/{databaseId}/executions' + .gsub('{databaseId}', database_id) + api_params = { sql: sql, bindings: bindings, @@ -965,13 +969,13 @@ def create_execution( def list_extensions( database_id: ) - api_path = '/postgresql/{databaseId}/extensions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/extensions' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -999,10 +1003,7 @@ def create_extension( database_id:, name: ) - api_path = '/postgresql/{databaseId}/extensions' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1010,6 +1011,9 @@ def create_extension( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/postgresql/{databaseId}/extensions' + .gsub('{databaseId}', database_id) + api_params = { name: name, } @@ -1040,18 +1044,18 @@ def delete_extension( database_id:, extension_name: ) - api_path = '/postgresql/{databaseId}/extensions/{extensionName}' - .gsub('{databaseId}', database_id) - .gsub('{extensionName}', extension_name) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if extension_name.nil? + if extension_name.nil? || extension_name == '' raise Appwrite::Exception.new('Missing required parameter: "extensionName"') end + api_path = '/postgresql/{databaseId}/extensions/{extensionName}' + .gsub('{databaseId}', database_id) + .gsub('{extensionName}', extension_name) + api_params = {} api_headers = { @@ -1087,13 +1091,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/postgresql/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1127,10 +1131,7 @@ def update_maintenance( day:, hour_utc: ) - api_path = '/postgresql/{databaseId}/maintenance' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1142,6 +1143,9 @@ def update_maintenance( raise Appwrite::Exception.new('Missing required parameter: "hourUtc"') end + api_path = '/postgresql/{databaseId}/maintenance' + .gsub('{databaseId}', database_id) + api_params = { day: day, hourUtc: hour_utc, @@ -1177,10 +1181,7 @@ def create_migration( target_type:, specification: nil ) - api_path = '/postgresql/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1188,6 +1189,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "targetType"') end + api_path = '/postgresql/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { targetType: target_type, specification: specification, @@ -1225,13 +1229,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/postgresql/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1261,13 +1265,13 @@ def list_operations( def get_pitr( database_id: ) - api_path = '/postgresql/{databaseId}/pitr' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/pitr' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1293,13 +1297,13 @@ def get_pitr( def get_pooler( database_id: ) - api_path = '/postgresql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1323,7 +1327,7 @@ def get_pooler( # @param [String] mode Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. # @param [Integer] max_connections Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. # @param [Integer] default_pool_size Default pool size per user. - # @param [] read_write_splitting Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. + # @param [] read_write_splitting Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. # @param [String] pooler_cpu_request Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). # @param [String] pooler_cpu_limit Pooler sidecar CPU limit override (Kubernetes quantity, e.g. "500m" or "1"). Leave null for the proportional default (10% of DB CPU, floor 200m). Changing this field rolls the database pod. # @param [String] pooler_memory_request Pooler sidecar memory request override (Kubernetes quantity, e.g. "128Mi" or "1Gi"). Leave null for the proportional default (7.5% of DB memory, floor 64Mi). @@ -1341,13 +1345,13 @@ def update_pooler( pooler_memory_request: nil, pooler_memory_limit: nil ) - api_path = '/postgresql/{databaseId}/pooler' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/pooler' + .gsub('{databaseId}', database_id) + api_params = { mode: mode, maxConnections: max_connections, @@ -1383,13 +1387,13 @@ def update_pooler( def get_replicas( database_id: ) - api_path = '/postgresql/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1423,13 +1427,13 @@ def list_restorations( limit: nil, offset: nil ) - api_path = '/postgresql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { status: status, type: type, @@ -1456,11 +1460,25 @@ def list_restorations( # an ISO 8601 datetime. PITR requires the database to have PITR enabled and # is only available for enterprise databases. # + # By default the backup is replayed over the database it was taken from. Pass + # `restoreMode` as `clone` to recover it onto a second workload beside this + # database instead: this database keeps serving its own data while the clone + # is filled, and the switch happens as soon as the clone is ready, on the + # endpoint and credentials it already had. Pass `autoPromote` as false to + # hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + # to recover onto a separate database with its own endpoint, either one you + # name with `targetDatabaseId` or one provisioned as a copy of this + # database's engine, version, specification and replicas. Neither mode is + # available for a point-in-time recovery or an incremental backup. + # # @param [String] database_id Database ID. # @param [String] type Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. # @param [String] backup_id Backup ID to restore from (required for backup type). - # @param [String] target_database_id Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. + # @param [String] target_database_id Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. # @param [String] target_time Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. + # @param [String] restore_mode Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. + # @param [String] target_name Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. + # @param [] auto_promote Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. # # @return [DedicatedDatabaseRestoration] def create_restoration( @@ -1468,20 +1486,26 @@ def create_restoration( type: nil, backup_id: nil, target_database_id: nil, - target_time: nil + target_time: nil, + restore_mode: nil, + target_name: nil, + auto_promote: nil ) - api_path = '/postgresql/{databaseId}/restorations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/restorations' + .gsub('{databaseId}', database_id) + api_params = { type: type, backupId: backup_id, targetDatabaseId: target_database_id, targetTime: target_time, + restoreMode: restore_mode, + targetName: target_name, + autoPromote: auto_promote, } api_headers = { @@ -1510,27 +1534,71 @@ def get_restoration( database_id:, restoration_id: ) + if database_id.nil? || database_id == '' + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if restoration_id.nil? || restoration_id == '' + raise Appwrite::Exception.new('Missing required parameter: "restorationId"') + end + api_path = '/postgresql/{databaseId}/restorations/{restorationId}' .gsub('{databaseId}', database_id) .gsub('{restorationId}', restoration_id) - if database_id.nil? + 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::DedicatedDatabaseRestoration + ) + end + + # Switch the database over to the clone a restoration recovered. The database + # keeps + # its endpoint and credentials; clients reconnect once. Writes made after the + # recovery point are discarded, and the side being replaced is retained + # briefly so + # the switch can be reversed. + # + # @param [String] database_id Database ID. + # @param [String] restoration_id Restoration ID. + # + # @return [DedicatedDatabaseRestoration] + def promote_restoration( + database_id:, + restoration_id: + ) + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if restoration_id.nil? + if restoration_id.nil? || restoration_id == '' raise Appwrite::Exception.new('Missing required parameter: "restorationId"') end + api_path = '/postgresql/{databaseId}/restorations/{restorationId}/promotions' + .gsub('{databaseId}', database_id) + .gsub('{restorationId}', restoration_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', "accept": 'application/json', } @client.call( - method: 'GET', + method: 'POST', path: api_path, headers: api_headers, params: api_params, @@ -1548,13 +1616,13 @@ def get_restoration( def get_status( database_id: ) - api_path = '/postgresql/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/postgresql/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1582,10 +1650,7 @@ def create_upgrade( database_id:, target_version: ) - api_path = '/postgresql/{databaseId}/upgrades' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -1593,6 +1658,9 @@ def create_upgrade( raise Appwrite::Exception.new('Missing required parameter: "targetVersion"') end + api_path = '/postgresql/{databaseId}/upgrades' + .gsub('{databaseId}', database_id) + api_params = { targetVersion: target_version, } diff --git a/lib/appwrite/services/presences.rb b/lib/appwrite/services/presences.rb index 01a022ed..a90a17d2 100644 --- a/lib/appwrite/services/presences.rb +++ b/lib/appwrite/services/presences.rb @@ -51,13 +51,13 @@ def list( def get( presence_id: ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = {} api_headers = { @@ -93,10 +93,7 @@ def upsert( expires_at: nil, metadata: nil ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end @@ -108,6 +105,9 @@ def upsert( raise Appwrite::Exception.new('Missing required parameter: "status"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = { userId: user_id, status: status, @@ -153,10 +153,7 @@ def update( permissions: nil, purge: nil ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end @@ -164,6 +161,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = { userId: user_id, status: status, @@ -197,18 +197,19 @@ def update( def delete( presence_id: ) - api_path = '/presences/{presenceId}' - .gsub('{presenceId}', presence_id) - - if presence_id.nil? + if presence_id.nil? || presence_id == '' raise Appwrite::Exception.new('Missing required parameter: "presenceId"') end + api_path = '/presences/{presenceId}' + .gsub('{presenceId}', presence_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/project.rb b/lib/appwrite/services/project.rb index 21ff2eb5..e5bc96b9 100644 --- a/lib/appwrite/services/project.rb +++ b/lib/appwrite/services/project.rb @@ -17,6 +17,7 @@ def get() api_headers = { "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', } @client.call( @@ -40,6 +41,7 @@ def delete() api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -53,7 +55,7 @@ def delete() # Update properties of a specific auth method. Use this endpoint to enable or # disable a method in your project. # - # @param [ProjectAuthMethodId] method_id Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone + # @param [ProjectAuthMethodId] method_id Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey # @param [] enabled Auth method status. # # @return [Project] @@ -61,9 +63,6 @@ def update_auth_method( method_id:, enabled: ) - api_path = '/project/auth-methods/{methodId}' - .gsub('{methodId}', method_id) - if method_id.nil? raise Appwrite::Exception.new('Missing required parameter: "methodId"') end @@ -72,6 +71,9 @@ def update_auth_method( raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/auth-methods/{methodId}' + .gsub('{methodId}', method_id) + api_params = { enabled: enabled, } @@ -173,7 +175,7 @@ def create_environment( def get_environment( environment_id: ) - if environment_id.nil? + if environment_id.nil? || environment_id == '' raise Appwrite::Exception.new('Missing required parameter: "environmentId"') end @@ -206,7 +208,7 @@ def update_environment( environment_id:, name: ) - if environment_id.nil? + if environment_id.nil? || environment_id == '' raise Appwrite::Exception.new('Missing required parameter: "environmentId"') end @@ -244,7 +246,7 @@ def update_environment( def delete_environment( environment_id: ) - if environment_id.nil? + if environment_id.nil? || environment_id == '' raise Appwrite::Exception.new('Missing required parameter: "environmentId"') end @@ -312,8 +314,6 @@ def create_ephemeral_key( scopes:, duration: ) - api_path = '/project/keys/ephemeral' - if scopes.nil? raise Appwrite::Exception.new('Missing required parameter: "scopes"') end @@ -322,6 +322,8 @@ def create_ephemeral_key( raise Appwrite::Exception.new('Missing required parameter: "duration"') end + api_path = '/project/keys/ephemeral' + api_params = { scopes: scopes, duration: duration, @@ -350,13 +352,13 @@ def create_ephemeral_key( def get_key( key_id: ) - api_path = '/project/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/project/keys/{keyId}' + .gsub('{keyId}', key_id) + api_params = {} api_headers = { @@ -388,10 +390,7 @@ def update_key( scopes:, expire: nil ) - api_path = '/project/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end @@ -403,6 +402,9 @@ def update_key( raise Appwrite::Exception.new('Missing required parameter: "scopes"') end + api_path = '/project/keys/{keyId}' + .gsub('{keyId}', key_id) + api_params = { name: name, scopes: scopes, @@ -433,18 +435,19 @@ def update_key( def delete_key( key_id: ) - api_path = '/project/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? + if key_id.nil? || key_id == '' raise Appwrite::Exception.new('Missing required parameter: "keyId"') end + api_path = '/project/keys/{keyId}' + .gsub('{keyId}', key_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -464,12 +467,12 @@ def delete_key( def update_labels( labels: ) - api_path = '/project/labels' - if labels.nil? raise Appwrite::Exception.new('Missing required parameter: "labels"') end + api_path = '/project/labels' + api_params = { labels: labels, } @@ -532,8 +535,6 @@ def create_mock_phone( number:, otp: ) - api_path = '/project/mock-phones' - if number.nil? raise Appwrite::Exception.new('Missing required parameter: "number"') end @@ -542,6 +543,8 @@ def create_mock_phone( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/project/mock-phones' + api_params = { number: number, otp: otp, @@ -571,13 +574,13 @@ def create_mock_phone( def get_mock_phone( number: ) - api_path = '/project/mock-phones/{number}' - .gsub('{number}', number) - - if number.nil? + if number.nil? || number == '' raise Appwrite::Exception.new('Missing required parameter: "number"') end + api_path = '/project/mock-phones/{number}' + .gsub('{number}', number) + api_params = {} api_headers = { @@ -605,10 +608,7 @@ def update_mock_phone( number:, otp: ) - api_path = '/project/mock-phones/{number}' - .gsub('{number}', number) - - if number.nil? + if number.nil? || number == '' raise Appwrite::Exception.new('Missing required parameter: "number"') end @@ -616,6 +616,9 @@ def update_mock_phone( raise Appwrite::Exception.new('Missing required parameter: "otp"') end + api_path = '/project/mock-phones/{number}' + .gsub('{number}', number) + api_params = { otp: otp, } @@ -644,18 +647,19 @@ def update_mock_phone( def delete_mock_phone( number: ) - api_path = '/project/mock-phones/{number}' - .gsub('{number}', number) - - if number.nil? + if number.nil? || number == '' raise Appwrite::Exception.new('Missing required parameter: "number"') end + api_path = '/project/mock-phones/{number}' + .gsub('{number}', number) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -737,8 +741,6 @@ def update_o_auth2_server( default_scopes: nil, installation_scopes: nil ) - api_path = '/project/oauth2-server' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end @@ -747,6 +749,8 @@ def update_o_auth2_server( raise Appwrite::Exception.new('Missing required parameter: "authorizationUrl"') end + api_path = '/project/oauth2-server' + api_params = { enabled: enabled, authorizationUrl: authorization_url, @@ -1597,23 +1601,23 @@ def update_o_auth2_hugging_face( # # @param [String] client_id 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de # @param [String] client_secret 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled - # @param [Array] prompt Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # @param [Array] prompt Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. # # @return [OAuth2Kakao] def update_o_auth2_kakao( client_id: nil, client_secret: nil, - prompt: nil, - enabled: nil + enabled: nil, + prompt: nil ) api_path = '/project/oauth2/kakao' api_params = { clientId: client_id, clientSecret: client_secret, - prompt: prompt, enabled: enabled, + prompt: prompt, } api_headers = { @@ -2595,13 +2599,13 @@ def update_o_auth2_zoom( def get_o_auth2_provider( provider_id: ) - api_path = '/project/oauth2/{providerId}' - .gsub('{providerId}', provider_id) - if provider_id.nil? raise Appwrite::Exception.new('Missing required parameter: "providerId"') end + api_path = '/project/oauth2/{providerId}' + .gsub('{providerId}', provider_id) + api_params = {} api_headers = { @@ -2901,8 +2905,6 @@ def create_android_platform( application_id:, fingerprints: nil ) - api_path = '/project/platforms/android' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -2915,6 +2917,8 @@ def create_android_platform( raise Appwrite::Exception.new('Missing required parameter: "applicationId"') end + api_path = '/project/platforms/android' + api_params = { platformId: platform_id, name: name, @@ -2938,7 +2942,7 @@ def create_android_platform( end # Update an Android platform by its unique ID. Use this endpoint to update - # the platform's name or application ID. + # the platform's name, application ID or signing certificate fingerprints. # # @param [String] platform_id Platform ID. # @param [String] name Platform name. Max length: 128 chars. @@ -2952,10 +2956,7 @@ def update_android_platform( application_id:, fingerprints: nil ) - api_path = '/project/platforms/android/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -2967,6 +2968,9 @@ def update_android_platform( raise Appwrite::Exception.new('Missing required parameter: "applicationId"') end + api_path = '/project/platforms/android/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, applicationId: application_id, @@ -3002,8 +3006,6 @@ def create_apple_platform( name:, bundle_identifier: ) - api_path = '/project/platforms/apple' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3016,6 +3018,8 @@ def create_apple_platform( raise Appwrite::Exception.new('Missing required parameter: "bundleIdentifier"') end + api_path = '/project/platforms/apple' + api_params = { platformId: platform_id, name: name, @@ -3050,10 +3054,7 @@ def update_apple_platform( name:, bundle_identifier: ) - api_path = '/project/platforms/apple/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3065,6 +3066,9 @@ def update_apple_platform( raise Appwrite::Exception.new('Missing required parameter: "bundleIdentifier"') end + api_path = '/project/platforms/apple/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, bundleIdentifier: bundle_identifier, @@ -3099,8 +3103,6 @@ def create_linux_platform( name:, package_name: ) - api_path = '/project/platforms/linux' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3113,6 +3115,8 @@ def create_linux_platform( raise Appwrite::Exception.new('Missing required parameter: "packageName"') end + api_path = '/project/platforms/linux' + api_params = { platformId: platform_id, name: name, @@ -3147,10 +3151,7 @@ def update_linux_platform( name:, package_name: ) - api_path = '/project/platforms/linux/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3162,6 +3163,9 @@ def update_linux_platform( raise Appwrite::Exception.new('Missing required parameter: "packageName"') end + api_path = '/project/platforms/linux/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, packageName: package_name, @@ -3196,8 +3200,6 @@ def create_web_platform( name:, hostname: ) - api_path = '/project/platforms/web' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3210,6 +3212,8 @@ def create_web_platform( raise Appwrite::Exception.new('Missing required parameter: "hostname"') end + api_path = '/project/platforms/web' + api_params = { platformId: platform_id, name: name, @@ -3244,10 +3248,7 @@ def update_web_platform( name:, hostname: ) - api_path = '/project/platforms/web/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3259,6 +3260,9 @@ def update_web_platform( raise Appwrite::Exception.new('Missing required parameter: "hostname"') end + api_path = '/project/platforms/web/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, hostname: hostname, @@ -3293,8 +3297,6 @@ def create_windows_platform( name:, package_identifier_name: ) - api_path = '/project/platforms/windows' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3307,6 +3309,8 @@ def create_windows_platform( raise Appwrite::Exception.new('Missing required parameter: "packageIdentifierName"') end + api_path = '/project/platforms/windows' + api_params = { platformId: platform_id, name: name, @@ -3341,10 +3345,7 @@ def update_windows_platform( name:, package_identifier_name: ) - api_path = '/project/platforms/windows/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -3356,6 +3357,9 @@ def update_windows_platform( raise Appwrite::Exception.new('Missing required parameter: "packageIdentifierName"') end + api_path = '/project/platforms/windows/{platformId}' + .gsub('{platformId}', platform_id) + api_params = { name: name, packageIdentifierName: package_identifier_name, @@ -3385,13 +3389,13 @@ def update_windows_platform( def get_platform( platform_id: ) - api_path = '/project/platforms/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end + api_path = '/project/platforms/{platformId}' + .gsub('{platformId}', platform_id) + api_params = {} api_headers = { @@ -3447,18 +3451,19 @@ def get_platform( def delete_platform( platform_id: ) - api_path = '/project/platforms/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end + api_path = '/project/platforms/{platformId}' + .gsub('{platformId}', platform_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3509,12 +3514,12 @@ def list_policies( def update_deny_aliased_email_policy( enabled: ) - api_path = '/project/policies/deny-aliased-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-aliased-email' + api_params = { enabled: enabled, } @@ -3543,12 +3548,12 @@ def update_deny_aliased_email_policy( def update_deny_corporate_email_policy( enabled: ) - api_path = '/project/policies/deny-corporate-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-corporate-email' + api_params = { enabled: enabled, } @@ -3577,12 +3582,12 @@ def update_deny_corporate_email_policy( def update_deny_disposable_email_policy( enabled: ) - api_path = '/project/policies/deny-disposable-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-disposable-email' + api_params = { enabled: enabled, } @@ -3611,12 +3616,12 @@ def update_deny_disposable_email_policy( def update_deny_free_email_policy( enabled: ) - api_path = '/project/policies/deny-free-email' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/deny-free-email' + api_params = { enabled: enabled, } @@ -3772,12 +3777,12 @@ def update_passkey_policy( def update_password_dictionary_policy( enabled: ) - api_path = '/project/policies/password-dictionary' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/password-dictionary' + api_params = { enabled: enabled, } @@ -3813,12 +3818,12 @@ def update_password_dictionary_policy( def update_password_history_policy( total: ) - api_path = '/project/policies/password-history' - if total.nil? raise Appwrite::Exception.new('Missing required parameter: "total"') end + api_path = '/project/policies/password-history' + api_params = { total: total, } @@ -3849,12 +3854,12 @@ def update_password_history_policy( def update_password_personal_data_policy( enabled: ) - api_path = '/project/policies/password-personal-data' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/password-personal-data' + api_params = { enabled: enabled, } @@ -4003,12 +4008,12 @@ def update_password_strength_policy( def update_session_alert_policy( enabled: ) - api_path = '/project/policies/session-alert' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/session-alert' + api_params = { enabled: enabled, } @@ -4037,12 +4042,12 @@ def update_session_alert_policy( def update_session_duration_policy( duration: ) - api_path = '/project/policies/session-duration' - if duration.nil? raise Appwrite::Exception.new('Missing required parameter: "duration"') end + api_path = '/project/policies/session-duration' + api_params = { duration: duration, } @@ -4072,12 +4077,12 @@ def update_session_duration_policy( def update_session_invalidation_policy( enabled: ) - api_path = '/project/policies/session-invalidation' - if enabled.nil? raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/policies/session-invalidation' + api_params = { enabled: enabled, } @@ -4106,12 +4111,12 @@ def update_session_invalidation_policy( def update_session_limit_policy( total: ) - api_path = '/project/policies/session-limit' - if total.nil? raise Appwrite::Exception.new('Missing required parameter: "total"') end + api_path = '/project/policies/session-limit' + api_params = { total: total, } @@ -4141,12 +4146,12 @@ def update_session_limit_policy( def update_user_limit_policy( total: ) - api_path = '/project/policies/user-limit' - if total.nil? raise Appwrite::Exception.new('Missing required parameter: "total"') end + api_path = '/project/policies/user-limit' + api_params = { total: total, } @@ -4169,19 +4174,19 @@ def update_user_limit_policy( # Get a policy by its unique ID. This endpoint returns the current # configuration for the requested project policy. # - # @param [ProjectPolicyId] policy_id Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + # @param [ProjectPolicyId] policy_id Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. # # @return [PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordStrength, PolicyPasswordPersonalData, PolicyPasswordPwned, PolicyPasswordRotation, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy, PolicyMfaFactors, PolicyDenyAliasedEmail, PolicyDenyDisposableEmail, PolicyDenyFreeEmail, PolicyDenyCorporateEmail, PolicyPasskey] def get_policy( policy_id: ) - api_path = '/project/policies/{policyId}' - .gsub('{policyId}', policy_id) - if policy_id.nil? raise Appwrite::Exception.new('Missing required parameter: "policyId"') end + api_path = '/project/policies/{policyId}' + .gsub('{policyId}', policy_id) + api_params = {} api_headers = { @@ -4304,9 +4309,6 @@ def update_protocol( protocol_id:, enabled: ) - api_path = '/project/protocols/{protocolId}' - .gsub('{protocolId}', protocol_id) - if protocol_id.nil? raise Appwrite::Exception.new('Missing required parameter: "protocolId"') end @@ -4315,6 +4317,9 @@ def update_protocol( raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/protocols/{protocolId}' + .gsub('{protocolId}', protocol_id) + api_params = { enabled: enabled, } @@ -4345,9 +4350,6 @@ def update_service( service_id:, enabled: ) - api_path = '/project/services/{serviceId}' - .gsub('{serviceId}', service_id) - if service_id.nil? raise Appwrite::Exception.new('Missing required parameter: "serviceId"') end @@ -4356,6 +4358,9 @@ def update_service( raise Appwrite::Exception.new('Missing required parameter: "enabled"') end + api_path = '/project/services/{serviceId}' + .gsub('{serviceId}', service_id) + api_params = { enabled: enabled, } @@ -4441,12 +4446,12 @@ def update_smtp( def create_smtp_test( emails: ) - api_path = '/project/smtp/tests' - if emails.nil? raise Appwrite::Exception.new('Missing required parameter: "emails"') end + api_path = '/project/smtp/tests' + api_params = { emails: emails, } @@ -4454,6 +4459,7 @@ def create_smtp_test( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -4500,7 +4506,7 @@ def list_email_templates( # Update a custom email template for the specified locale and type. Use this # endpoint to modify the content of your email templates. # - # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery # @param [ProjectEmailTemplateLocale] locale Custom email template locale. If left empty, the fallback locale (en) will be used. # @param [String] subject Subject of the email template. Can be up to 255 characters. # @param [String] message Plain or HTML body of the email template message. Can be up to 10MB of content. @@ -4520,12 +4526,12 @@ def update_email_template( reply_to_email: nil, reply_to_name: nil ) - api_path = '/project/templates/email' - if template_id.nil? raise Appwrite::Exception.new('Missing required parameter: "templateId"') end + api_path = '/project/templates/email' + api_params = { templateId: template_id, locale: locale, @@ -4556,7 +4562,7 @@ def update_email_template( # endpoint returns the template content, subject, and other configuration # details. # - # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + # @param [ProjectEmailTemplateId] template_id Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery # @param [ProjectEmailTemplateLocale] locale Custom email template locale. If left empty, the fallback locale (en) will be used. # # @return [EmailTemplate] @@ -4564,13 +4570,13 @@ def get_email_template( template_id:, locale: nil ) - api_path = '/project/templates/email/{templateId}' - .gsub('{templateId}', template_id) - if template_id.nil? raise Appwrite::Exception.new('Missing required parameter: "templateId"') end + api_path = '/project/templates/email/{templateId}' + .gsub('{templateId}', template_id) + api_params = { locale: locale, } @@ -4635,8 +4641,6 @@ def create_variable( value:, secret: nil ) - api_path = '/project/variables' - if variable_id.nil? raise Appwrite::Exception.new('Missing required parameter: "variableId"') end @@ -4649,6 +4653,8 @@ def create_variable( raise Appwrite::Exception.new('Missing required parameter: "value"') end + api_path = '/project/variables' + api_params = { variableId: variable_id, key: key, @@ -4679,13 +4685,13 @@ def create_variable( def get_variable( variable_id: ) - api_path = '/project/variables/{variableId}' - .gsub('{variableId}', variable_id) - - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/project/variables/{variableId}' + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { @@ -4716,13 +4722,13 @@ def update_variable( value: nil, secret: nil ) - api_path = '/project/variables/{variableId}' - .gsub('{variableId}', variable_id) - - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/project/variables/{variableId}' + .gsub('{variableId}', variable_id) + api_params = { key: key, value: value, @@ -4752,18 +4758,19 @@ def update_variable( def delete_variable( variable_id: ) - api_path = '/project/variables/{variableId}' - .gsub('{variableId}', variable_id) - - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/project/variables/{variableId}' + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/proxy.rb b/lib/appwrite/services/proxy.rb index 48d11c6d..b84b9b2d 100644 --- a/lib/appwrite/services/proxy.rb +++ b/lib/appwrite/services/proxy.rb @@ -12,6 +12,8 @@ def initialize(client) # Depending on type, the invalidation purges a single cache tag, a single URL # path, or all cached content for the domain. # + # Domains that route to a function do not support cache invalidation. + # # @param [String] domain Domain name. # @param [InvalidationType] type Type of reference passed. Allowed values are: tag, path, all # @param [String] reference Reference to invalidate. Depending on type this can be: cache tag name (up to 128 characters), URL path (up to 2048 characters). Not required when type is all. @@ -22,8 +24,6 @@ def create_invalidation( type:, reference: nil ) - api_path = '/proxy/invalidations' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -32,6 +32,8 @@ def create_invalidation( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/proxy/invalidations' + api_params = { domain: domain, type: type, @@ -56,7 +58,7 @@ def create_invalidation( # Get a list of all the proxy rules. You can use the query params to filter # your results. # - # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch, protocol # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [ProxyRuleList] @@ -96,12 +98,12 @@ def list_rules( def create_api_rule( domain: ) - api_path = '/proxy/rules/api' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end + api_path = '/proxy/rules/api' + api_params = { domain: domain, } @@ -136,8 +138,6 @@ def create_function_rule( function_id:, branch: nil ) - api_path = '/proxy/rules/function' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -146,6 +146,8 @@ def create_function_rule( raise Appwrite::Exception.new('Missing required parameter: "functionId"') end + api_path = '/proxy/rules/function' + api_params = { domain: domain, functionId: function_id, @@ -187,8 +189,6 @@ def create_redirect_rule( resource_id:, resource_type: ) - api_path = '/proxy/rules/redirect' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -209,6 +209,8 @@ def create_redirect_rule( raise Appwrite::Exception.new('Missing required parameter: "resourceType"') end + api_path = '/proxy/rules/redirect' + api_params = { domain: domain, url: url, @@ -247,8 +249,6 @@ def create_site_rule( site_id:, branch: nil ) - api_path = '/proxy/rules/site' - if domain.nil? raise Appwrite::Exception.new('Missing required parameter: "domain"') end @@ -257,6 +257,8 @@ def create_site_rule( raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/proxy/rules/site' + api_params = { domain: domain, siteId: site_id, @@ -278,6 +280,50 @@ def create_site_rule( ) end + # Create an SMTP ingress rule that asynchronously executes an Appwrite + # Function for incoming email. + # + # @param [String] domain Domain that receives email. + # @param [String] function_id ID of function to execute. + # @param [String] branch Name of VCS branch to deploy changes automatically. + # + # @return [ProxyRule] + def create_smtp_rule( + domain:, + function_id:, + branch: nil + ) + if domain.nil? + raise Appwrite::Exception.new('Missing required parameter: "domain"') + end + + if function_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "functionId"') + end + + api_path = '/proxy/rules/smtp' + + api_params = { + domain: domain, + functionId: function_id, + branch: branch, + } + + 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::ProxyRule + ) + end + # Get a proxy rule by its unique ID. # # @param [String] rule_id Rule ID. @@ -286,13 +332,13 @@ def create_site_rule( def get_rule( rule_id: ) - api_path = '/proxy/rules/{ruleId}' - .gsub('{ruleId}', rule_id) - - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end + api_path = '/proxy/rules/{ruleId}' + .gsub('{ruleId}', rule_id) + api_params = {} api_headers = { @@ -317,18 +363,19 @@ def get_rule( def delete_rule( rule_id: ) - api_path = '/proxy/rules/{ruleId}' - .gsub('{ruleId}', rule_id) - - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end + api_path = '/proxy/rules/{ruleId}' + .gsub('{ruleId}', rule_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -350,13 +397,13 @@ def delete_rule( def update_rule_status( rule_id: ) - api_path = '/proxy/rules/{ruleId}/status' - .gsub('{ruleId}', rule_id) - - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end + api_path = '/proxy/rules/{ruleId}/status' + .gsub('{ruleId}', rule_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/sites.rb b/lib/appwrite/services/sites.rb index 46a830f2..9a7d793e 100644 --- a/lib/appwrite/services/sites.rb +++ b/lib/appwrite/services/sites.rb @@ -95,8 +95,6 @@ def create( deployment_retention: nil, scopes: nil ) - api_path = '/sites' - if site_id.nil? raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -113,6 +111,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "buildRuntime"') end + api_path = '/sites' + api_params = { siteId: site_id, name: name, @@ -223,13 +223,13 @@ def list_specifications( def get( site_id: ) - api_path = '/sites/{siteId}' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}' + .gsub('{siteId}', site_id) + api_params = {} api_headers = { @@ -300,10 +300,7 @@ def update( deployment_retention: nil, scopes: nil ) - api_path = '/sites/{siteId}' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -315,6 +312,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "framework"') end + api_path = '/sites/{siteId}' + .gsub('{siteId}', site_id) + api_params = { name: name, framework: framework, @@ -364,18 +364,19 @@ def update( def delete( site_id: ) - api_path = '/sites/{siteId}' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}' + .gsub('{siteId}', site_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -397,10 +398,7 @@ def update_site_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployment' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -408,6 +406,9 @@ def update_site_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployment' + .gsub('{siteId}', site_id) + api_params = { deploymentId: deployment_id, } @@ -442,13 +443,13 @@ def list_deployments( search: nil, total: nil ) - api_path = '/sites/{siteId}/deployments' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}/deployments' + .gsub('{siteId}', site_id) + api_params = { queries: queries, search: search, @@ -490,10 +491,7 @@ def create_deployment( activate: nil, on_progress: nil ) - api_path = '/sites/{siteId}/deployments' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -501,6 +499,9 @@ def create_deployment( raise Appwrite::Exception.new('Missing required parameter: "code"') end + api_path = '/sites/{siteId}/deployments' + .gsub('{siteId}', site_id) + api_params = { installCommand: install_command, buildCommand: build_command, @@ -525,6 +526,7 @@ def create_deployment( param_name: param_name, id_param_name: id_param_name, on_progress: on_progress, + method: 'POST', response_type: Models::Deployment ) end @@ -543,10 +545,7 @@ def create_duplicate_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/duplicate' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -554,6 +553,9 @@ def create_duplicate_deployment( raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/duplicate' + .gsub('{siteId}', site_id) + api_params = { deploymentId: deployment_id, } @@ -597,10 +599,7 @@ def create_template_deployment( reference:, activate: nil ) - api_path = '/sites/{siteId}/deployments/template' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -624,6 +623,9 @@ def create_template_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/sites/{siteId}/deployments/template' + .gsub('{siteId}', site_id) + api_params = { repository: repository, owner: owner, @@ -664,10 +666,7 @@ def create_vcs_deployment( reference:, activate: nil ) - api_path = '/sites/{siteId}/deployments/vcs' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -679,6 +678,9 @@ def create_vcs_deployment( raise Appwrite::Exception.new('Missing required parameter: "reference"') end + api_path = '/sites/{siteId}/deployments/vcs' + .gsub('{siteId}', site_id) + api_params = { type: type, reference: reference, @@ -710,18 +712,18 @@ def get_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/{deploymentId}' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -748,23 +750,24 @@ def delete_deployment( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/{deploymentId}' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -791,18 +794,18 @@ def get_deployment_download( type: nil, token: nil ) - api_path = '/sites/{siteId}/deployments/{deploymentId}/download' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}/download' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = { type: type, token: token, @@ -835,18 +838,18 @@ def update_deployment_status( site_id:, deployment_id: ) - api_path = '/sites/{siteId}/deployments/{deploymentId}/status' - .gsub('{siteId}', site_id) - .gsub('{deploymentId}', deployment_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if deployment_id.nil? + if deployment_id.nil? || deployment_id == '' raise Appwrite::Exception.new('Missing required parameter: "deploymentId"') end + api_path = '/sites/{siteId}/deployments/{deploymentId}/status' + .gsub('{siteId}', site_id) + .gsub('{deploymentId}', deployment_id) + api_params = {} api_headers = { @@ -877,13 +880,13 @@ def list_logs( queries: nil, total: nil ) - api_path = '/sites/{siteId}/logs' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}/logs' + .gsub('{siteId}', site_id) + api_params = { queries: queries, total: total, @@ -913,18 +916,18 @@ def get_log( site_id:, log_id: ) - api_path = '/sites/{siteId}/logs/{logId}' - .gsub('{siteId}', site_id) - .gsub('{logId}', log_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if log_id.nil? + if log_id.nil? || log_id == '' raise Appwrite::Exception.new('Missing required parameter: "logId"') end + api_path = '/sites/{siteId}/logs/{logId}' + .gsub('{siteId}', site_id) + .gsub('{logId}', log_id) + api_params = {} api_headers = { @@ -951,18 +954,18 @@ def delete_log( site_id:, log_id: ) - api_path = '/sites/{siteId}/logs/{logId}' - .gsub('{siteId}', site_id) - .gsub('{logId}', log_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if log_id.nil? + if log_id.nil? || log_id == '' raise Appwrite::Exception.new('Missing required parameter: "logId"') end + api_path = '/sites/{siteId}/logs/{logId}' + .gsub('{siteId}', site_id) + .gsub('{logId}', log_id) + api_params = {} api_headers = { @@ -991,13 +994,13 @@ def list_variables( queries: nil, total: nil ) - api_path = '/sites/{siteId}/variables' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end + api_path = '/sites/{siteId}/variables' + .gsub('{siteId}', site_id) + api_params = { queries: queries, total: total, @@ -1034,10 +1037,7 @@ def create_variable( value:, secret: nil ) - api_path = '/sites/{siteId}/variables' - .gsub('{siteId}', site_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end @@ -1053,6 +1053,9 @@ def create_variable( raise Appwrite::Exception.new('Missing required parameter: "value"') end + api_path = '/sites/{siteId}/variables' + .gsub('{siteId}', site_id) + api_params = { variableId: variable_id, key: key, @@ -1085,18 +1088,18 @@ def get_variable( site_id:, variable_id: ) - api_path = '/sites/{siteId}/variables/{variableId}' - .gsub('{siteId}', site_id) - .gsub('{variableId}', variable_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/sites/{siteId}/variables/{variableId}' + .gsub('{siteId}', site_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { @@ -1129,18 +1132,18 @@ def update_variable( value: nil, secret: nil ) - api_path = '/sites/{siteId}/variables/{variableId}' - .gsub('{siteId}', site_id) - .gsub('{variableId}', variable_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/sites/{siteId}/variables/{variableId}' + .gsub('{siteId}', site_id) + .gsub('{variableId}', variable_id) + api_params = { key: key, value: value, @@ -1172,23 +1175,24 @@ def delete_variable( site_id:, variable_id: ) - api_path = '/sites/{siteId}/variables/{variableId}' - .gsub('{siteId}', site_id) - .gsub('{variableId}', variable_id) - - if site_id.nil? + if site_id.nil? || site_id == '' raise Appwrite::Exception.new('Missing required parameter: "siteId"') end - if variable_id.nil? + if variable_id.nil? || variable_id == '' raise Appwrite::Exception.new('Missing required parameter: "variableId"') end + api_path = '/sites/{siteId}/variables/{variableId}' + .gsub('{siteId}', site_id) + .gsub('{variableId}', variable_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/storage.rb b/lib/appwrite/services/storage.rb index 18389d90..1938edd1 100644 --- a/lib/appwrite/services/storage.rb +++ b/lib/appwrite/services/storage.rb @@ -69,8 +69,6 @@ def create_bucket( antivirus: nil, transformations: nil ) - api_path = '/storage/buckets' - if bucket_id.nil? raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end @@ -79,6 +77,8 @@ def create_bucket( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/storage/buckets' + api_params = { bucketId: bucket_id, name: name, @@ -117,13 +117,13 @@ def create_bucket( def get_bucket( bucket_id: ) - api_path = '/storage/buckets/{bucketId}' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end + api_path = '/storage/buckets/{bucketId}' + .gsub('{bucketId}', bucket_id) + api_params = {} api_headers = { @@ -168,10 +168,7 @@ def update_bucket( antivirus: nil, transformations: nil ) - api_path = '/storage/buckets/{bucketId}' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end @@ -179,6 +176,9 @@ def update_bucket( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/storage/buckets/{bucketId}' + .gsub('{bucketId}', bucket_id) + api_params = { name: name, permissions: permissions, @@ -215,18 +215,19 @@ def update_bucket( def delete_bucket( bucket_id: ) - api_path = '/storage/buckets/{bucketId}' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end + api_path = '/storage/buckets/{bucketId}' + .gsub('{bucketId}', bucket_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -252,13 +253,13 @@ def list_files( search: nil, total: nil ) - api_path = '/storage/buckets/{bucketId}/files' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end + api_path = '/storage/buckets/{bucketId}/files' + .gsub('{bucketId}', bucket_id) + api_params = { queries: queries, search: search, @@ -313,10 +314,7 @@ def create_file( folder: nil, on_progress: nil ) - api_path = '/storage/buckets/{bucketId}/files' - .gsub('{bucketId}', bucket_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end @@ -328,6 +326,9 @@ def create_file( raise Appwrite::Exception.new('Missing required parameter: "file"') end + api_path = '/storage/buckets/{bucketId}/files' + .gsub('{bucketId}', bucket_id) + api_params = { fileId: file_id, file: file, @@ -351,6 +352,7 @@ def create_file( param_name: param_name, id_param_name: id_param_name, on_progress: on_progress, + method: 'POST', response_type: Models::File ) end @@ -366,18 +368,18 @@ def get_file( bucket_id:, file_id: ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = {} api_headers = { @@ -409,18 +411,18 @@ def update_file( name: nil, permissions: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { name: name, permissions: permissions, @@ -452,23 +454,24 @@ def delete_file( bucket_id:, file_id: ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -493,18 +496,18 @@ def get_file_download( file_id:, token: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}/download' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}/download' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { token: token, } @@ -532,7 +535,7 @@ def get_file_download( # @param [String] file_id File ID # @param [Integer] width Resize preview image width, Pass an integer between 0 to 4000. # @param [Integer] height Resize preview image height, Pass an integer between 0 to 4000. - # @param [ImageGravity] gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right + # @param [ImageGravity] gravity Image crop gravity. Can be one of auto,center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right # @param [Integer] quality Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. # @param [Integer] border_width Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. # @param [String] border_color Preview image border color. Use a valid HEX color, no # is needed for prefix. @@ -560,18 +563,18 @@ def get_file_preview( output: nil, token: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}/preview' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}/preview' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { width: width, height: height, @@ -614,18 +617,18 @@ def get_file_view( file_id:, token: nil ) - api_path = '/storage/buckets/{bucketId}/files/{fileId}/view' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/storage/buckets/{bucketId}/files/{fileId}/view' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { token: token, } diff --git a/lib/appwrite/services/tables_db.rb b/lib/appwrite/services/tables_db.rb index ef709de8..ac85cdf8 100644 --- a/lib/appwrite/services/tables_db.rb +++ b/lib/appwrite/services/tables_db.rb @@ -60,8 +60,6 @@ def create( replicas: nil, sync_mode: nil ) - api_path = '/tablesdb' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -70,6 +68,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/tablesdb' + api_params = { databaseId: database_id, name: name, @@ -95,8 +95,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -187,13 +187,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/tablesdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -222,13 +222,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/tablesdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -257,18 +257,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/tablesdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -289,13 +290,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/tablesdb/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/tablesdb/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -324,13 +325,13 @@ def create_operations( def get( database_id: ) - api_path = '/tablesdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -365,13 +366,13 @@ def update( replicas: nil, sync_mode: nil ) - api_path = '/tablesdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -404,18 +405,19 @@ def update( def delete( database_id: ) - api_path = '/tablesdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -444,13 +446,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/tablesdb/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -479,13 +481,13 @@ def create_failover( def list_migrations( database_id: ) - api_path = '/tablesdb/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -503,8 +505,13 @@ def list_migrations( end # Start migrating a serverless TablesDB database onto a dedicated MySQL - # compute. Data is copied to the target while the source stays live, with a - # brief read-only window during cutover. + # compute. Data is copied to the target while the source stays live. Reads + # continue throughout. Row writes are held for up to a few seconds while + # routing switches to the dedicated compute; a write the switch has not + # absorbed within that hold is refused with `database_migration_cutover` and + # can be retried. Schema changes (tables, columns, indexes) are refused from + # creation until the cutover completes, and resume once the migration is + # `soaking`. # # @param [String] database_id Database ID. # @param [String] specification Dedicated compute specification to provision as the migration target (e.g. s-2vcpu-4gb). The migration always targets a dedicated compute, so `serverless` is not accepted. @@ -516,10 +523,7 @@ def create_migration( specification:, auto_cutover: nil ) - api_path = '/tablesdb/{databaseId}/migrations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -527,6 +531,9 @@ def create_migration( raise Appwrite::Exception.new('Missing required parameter: "specification"') end + api_path = '/tablesdb/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + api_params = { specification: specification, autoCutover: auto_cutover, @@ -557,18 +564,18 @@ def get_migration( database_id:, migration_id: ) - api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' - .gsub('{databaseId}', database_id) - .gsub('{migrationId}', migration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if migration_id.nil? + if migration_id.nil? || migration_id == '' raise Appwrite::Exception.new('Missing required parameter: "migrationId"') end + api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' + .gsub('{databaseId}', database_id) + .gsub('{migrationId}', migration_id) + api_params = {} api_headers = { @@ -596,18 +603,18 @@ def delete_migration( database_id:, migration_id: ) - api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' - .gsub('{databaseId}', database_id) - .gsub('{migrationId}', migration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if migration_id.nil? + if migration_id.nil? || migration_id == '' raise Appwrite::Exception.new('Missing required parameter: "migrationId"') end + api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' + .gsub('{databaseId}', database_id) + .gsub('{migrationId}', migration_id) + api_params = {} api_headers = { @@ -627,9 +634,12 @@ def delete_migration( # Cut a verified TablesDB migration over to its dedicated compute. Only # applies to a migration created with `autoCutover` disabled, which waits at # `ready_to_cutover` until this is called. The routing flip happens shortly - # after this returns, with a brief read-only window. One call buys one - # attempt: a cutover that fails a check returns the migration to `verifying` - # and parks it again, so call this once more to retry. + # after this returns. Reads are unaffected; row writes are held for up to a + # few seconds while it lands, and a write the flip has not absorbed within + # that hold is refused with `database_migration_cutover` and can be retried. + # One call buys one attempt: a cutover that fails a check returns the + # migration to `verifying` and parks it again, so call this once more to + # retry. # # @param [String] database_id Database ID. # @param [String] migration_id Migration ID. @@ -639,18 +649,18 @@ def create_cutover( database_id:, migration_id: ) - api_path = '/tablesdb/{databaseId}/migrations/{migrationId}/cutovers' - .gsub('{databaseId}', database_id) - .gsub('{migrationId}', migration_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if migration_id.nil? + if migration_id.nil? || migration_id == '' raise Appwrite::Exception.new('Missing required parameter: "migrationId"') end + api_path = '/tablesdb/{databaseId}/migrations/{migrationId}/cutovers' + .gsub('{databaseId}', database_id) + .gsub('{migrationId}', migration_id) + api_params = {} api_headers = { @@ -685,13 +695,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/tablesdb/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -721,13 +731,13 @@ def list_operations( def get_replicas( database_id: ) - api_path = '/tablesdb/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -754,13 +764,13 @@ def get_replicas( def get_status( database_id: ) - api_path = '/tablesdb/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -792,13 +802,13 @@ def list_tables( search: nil, total: nil ) - api_path = '/tablesdb/{databaseId}/tables' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/tablesdb/{databaseId}/tables' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -831,7 +841,7 @@ def list_tables( # @param [] row_security Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] enabled Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. # @param [Array] columns Array of column definitions to create. Each column should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. - # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). # # @return [Table] def create_table( @@ -844,10 +854,7 @@ def create_table( columns: nil, indexes: nil ) - api_path = '/tablesdb/{databaseId}/tables' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -859,6 +866,9 @@ def create_table( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/tablesdb/{databaseId}/tables' + .gsub('{databaseId}', database_id) + api_params = { tableId: table_id, name: name, @@ -895,18 +905,18 @@ def get_table( database_id:, table_id: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = {} api_headers = { @@ -943,18 +953,18 @@ def update_table( enabled: nil, purge: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { name: name, permissions: permissions, @@ -989,23 +999,24 @@ def delete_table( database_id:, table_id: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1030,18 +1041,18 @@ def list_columns( queries: nil, total: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, total: total, @@ -1085,15 +1096,11 @@ def create_big_int_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1105,6 +1112,10 @@ def create_big_int_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1153,20 +1164,15 @@ def update_big_int_column( max: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1178,6 +1184,11 @@ def update_big_int_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1220,15 +1231,11 @@ def create_boolean_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1240,6 +1247,10 @@ def create_boolean_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1281,20 +1292,15 @@ def update_boolean_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1306,6 +1312,11 @@ def update_boolean_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1345,15 +1356,11 @@ def create_datetime_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1365,6 +1372,10 @@ def create_datetime_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1406,20 +1417,15 @@ def update_datetime_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1431,6 +1437,11 @@ def update_datetime_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1471,15 +1482,11 @@ def create_email_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1491,6 +1498,10 @@ def create_email_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1533,20 +1544,15 @@ def update_email_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1558,6 +1564,11 @@ def update_email_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -1600,15 +1611,11 @@ def create_enum_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1624,6 +1631,10 @@ def create_enum_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, elements: elements, @@ -1669,20 +1680,15 @@ def update_enum_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1698,6 +1704,11 @@ def update_enum_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { elements: elements, required: required, @@ -1744,15 +1755,11 @@ def create_float_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1764,6 +1771,10 @@ def create_float_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1812,20 +1823,15 @@ def update_float_column( max: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1837,6 +1843,11 @@ def update_float_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -1884,15 +1895,11 @@ def create_integer_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -1904,6 +1911,10 @@ def create_integer_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -1952,20 +1963,15 @@ def update_integer_column( max: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -1977,6 +1983,11 @@ def update_integer_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, min: min, @@ -2019,15 +2030,11 @@ def create_ip_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2039,6 +2046,10 @@ def create_ip_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2081,20 +2092,15 @@ def update_ip_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2106,6 +2112,11 @@ def update_ip_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2143,15 +2154,11 @@ def create_line_column( required:, default: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2163,6 +2170,10 @@ def create_line_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2203,20 +2214,15 @@ def update_line_column( default: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2224,6 +2230,11 @@ def update_line_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2266,15 +2277,11 @@ def create_longtext_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2286,6 +2293,10 @@ def create_longtext_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2329,20 +2340,15 @@ def update_longtext_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2354,6 +2360,11 @@ def update_longtext_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2396,15 +2407,11 @@ def create_mediumtext_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2416,6 +2423,10 @@ def create_mediumtext_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2459,20 +2470,15 @@ def update_mediumtext_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2484,6 +2490,11 @@ def update_mediumtext_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2521,15 +2532,11 @@ def create_point_column( required:, default: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2541,6 +2548,10 @@ def create_point_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2581,20 +2592,15 @@ def update_point_column( default: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2602,6 +2608,11 @@ def update_point_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2639,15 +2650,11 @@ def create_polygon_column( required:, default: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2659,6 +2666,10 @@ def create_polygon_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -2699,20 +2710,15 @@ def update_polygon_column( default: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2720,6 +2726,11 @@ def update_polygon_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2765,15 +2776,11 @@ def create_relationship_column( two_way_key: nil, on_delete: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2785,6 +2792,10 @@ def create_relationship_column( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { relatedTableId: related_table_id, type: type, @@ -2809,41 +2820,92 @@ def create_relationship_column( ) end - # - # @deprecated This API has been deprecated since 1.9.0. Please use `TablesDB.createTextColumn` instead. - # - # Create a string column. + # Update relationship column. [Learn more about relationship + # columns](https://appwrite.io/docs/databases-relationships#relationship-columns). # # # @param [String] database_id Database ID. - # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] table_id Table ID. # @param [String] key Column Key. - # @param [Integer] size Column size for text columns, in number of characters. - # @param [] required Is column required? - # @param [String] default Default value for column when not provided. Cannot be set when column is required. - # @param [] array Is column an array? - # @param [] encrypt Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + # @param [RelationMutate] on_delete Delete constraint. Possible values are: cascade, restrict, setNull. + # @param [String] new_key New Column Key. # - # @return [ColumnString] - def create_string_column( + # @return [ColumnRelationship] + def update_relationship_column( database_id:, table_id:, key:, - size:, - required:, - default: nil, - array: nil, - encrypt: nil + on_delete: nil, + new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string' - .gsub('{databaseId}', database_id) + if database_id.nil? || database_id == '' + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if table_id.nil? || table_id == '' + raise Appwrite::Exception.new('Missing required parameter: "tableId"') + end + + if key.nil? || key == '' + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key}' + .gsub('{databaseId}', database_id) .gsub('{tableId}', table_id) + .gsub('{key}', key) - if database_id.nil? + api_params = { + onDelete: on_delete, + newKey: new_key, + } + + 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::ColumnRelationship + ) + end + + # + # @deprecated This API has been deprecated since 1.9.0. Please use `TablesDB.createTextColumn` instead. + # + # Create a string column. + # + # + # @param [String] database_id Database ID. + # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] key Column Key. + # @param [Integer] size Column size for text columns, in number of characters. + # @param [] required Is column required? + # @param [String] default Default value for column when not provided. Cannot be set when column is required. + # @param [] array Is column an array? + # @param [] encrypt Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + # + # @return [ColumnString] + def create_string_column( + database_id:, + table_id:, + key:, + size:, + required:, + default: nil, + array: nil, + encrypt: nil + ) + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2859,6 +2921,10 @@ def create_string_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, size: size, @@ -2908,20 +2974,15 @@ def update_string_column( size: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -2933,6 +2994,11 @@ def update_string_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -2976,15 +3042,11 @@ def create_text_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -2996,6 +3058,10 @@ def create_text_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -3039,20 +3105,15 @@ def update_text_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3064,6 +3125,11 @@ def update_text_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3104,15 +3170,11 @@ def create_url_column( default: nil, array: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3124,6 +3186,10 @@ def create_url_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, required: required, @@ -3166,20 +3232,15 @@ def update_url_column( default:, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3191,6 +3252,11 @@ def update_url_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3235,15 +3301,11 @@ def create_varchar_column( array: nil, encrypt: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3259,6 +3321,10 @@ def create_varchar_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, size: size, @@ -3305,20 +3371,15 @@ def update_varchar_column( size: nil, new_key: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end @@ -3330,6 +3391,11 @@ def update_varchar_column( raise Appwrite::Exception.new('Missing required parameter: "default"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = { required: required, default: default, @@ -3358,29 +3424,29 @@ def update_varchar_column( # @param [String] table_id Table ID. # @param [String] key Column Key. # - # @return [ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnString] + # @return [ColumnBoolean, ColumnBigint, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnPoint, ColumnLine, ColumnPolygon, ColumnVarchar, ColumnText, ColumnMediumtext, ColumnLongtext, ColumnString] def get_column( database_id:, table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -3424,6 +3490,11 @@ def get_column( return Models::ColumnBoolean.from(map: response) end + if response['type'] == 'bigint' + + return Models::ColumnBigint.from(map: response) + end + if response['type'] == 'integer' return Models::ColumnInteger.from(map: response) @@ -3444,6 +3515,41 @@ def get_column( return Models::ColumnRelationship.from(map: response) end + if response['type'] == 'point' + + return Models::ColumnPoint.from(map: response) + end + + if response['type'] == 'linestring' + + return Models::ColumnLine.from(map: response) + end + + if response['type'] == 'polygon' + + return Models::ColumnPolygon.from(map: response) + end + + if response['type'] == 'varchar' + + return Models::ColumnVarchar.from(map: response) + end + + if response['type'] == 'text' + + return Models::ColumnText.from(map: response) + end + + if response['type'] == 'mediumtext' + + return Models::ColumnMediumtext.from(map: response) + end + + if response['type'] == 'longtext' + + return Models::ColumnLongtext.from(map: response) + end + if response['type'] == 'string' return Models::ColumnString.from(map: response) @@ -3464,77 +3570,24 @@ def delete_column( table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end - api_params = {} - - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), - "content-type": 'application/json', - } - - @client.call( - method: 'DELETE', - path: api_path, - headers: api_headers, - params: api_params, - ) - end - - # Update relationship column. [Learn more about relationship - # columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - # - # - # @param [String] database_id Database ID. - # @param [String] table_id Table ID. - # @param [String] key Column Key. - # @param [RelationMutate] on_delete Delete constraint. Possible values are: cascade, restrict, setNull. - # @param [String] new_key New Column Key. - # - # @return [ColumnRelationship] - def update_relationship_column( - database_id:, - table_id:, - key:, - on_delete: nil, - new_key: nil - ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship' + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' .gsub('{databaseId}', database_id) .gsub('{tableId}', table_id) .gsub('{key}', key) - if database_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "databaseId"') - end - - if table_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "tableId"') - end - - if key.nil? - raise Appwrite::Exception.new('Missing required parameter: "key"') - end - - api_params = { - onDelete: on_delete, - newKey: new_key, - } + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -3543,11 +3596,10 @@ def update_relationship_column( } @client.call( - method: 'PATCH', + method: 'DELETE', path: api_path, headers: api_headers, params: api_params, - response_type: Models::ColumnRelationship ) end @@ -3565,18 +3617,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, total: total, @@ -3598,7 +3650,9 @@ def list_indexes( # Creates an index on the columns listed. Your index should include all the # columns you will query in a single request. - # Type can be `key`, `fulltext`, or `unique`. + # Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` + # is only available on PostgreSQL and lets `contains`, `startsWith`, and + # `endsWith` queries on string columns use an index. # # @param [String] database_id Database ID. # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). @@ -3618,15 +3672,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3642,6 +3692,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "columns"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { key: key, type: type, @@ -3677,23 +3731,23 @@ def get_index( table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -3722,28 +3776,29 @@ def delete_index( table_id:, key: ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3773,18 +3828,18 @@ def list_rows( total: nil, ttl: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -3827,15 +3882,11 @@ def create_row( permissions: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3847,6 +3898,10 @@ def create_row( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { rowId: row_id, data: data, @@ -3886,15 +3941,11 @@ def create_rows( rows:, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3902,6 +3953,10 @@ def create_rows( raise Appwrite::Exception.new('Missing required parameter: "rows"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { rows: rows, transactionId: transaction_id, @@ -3940,15 +3995,11 @@ def upsert_rows( rows:, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end @@ -3956,6 +4007,10 @@ def upsert_rows( raise Appwrite::Exception.new('Missing required parameter: "rows"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { rows: rows, transactionId: transaction_id, @@ -3993,18 +4048,18 @@ def update_rows( queries: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { data: data, queries: queries, @@ -4041,18 +4096,18 @@ def delete_rows( queries: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -4090,23 +4145,23 @@ def get_row( queries: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -4147,23 +4202,23 @@ def upsert_row( permissions: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { data: data, permissions: permissions, @@ -4204,23 +4259,23 @@ def update_row( permissions: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { data: data, permissions: permissions, @@ -4256,23 +4311,23 @@ def delete_row( row_id:, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + api_params = { transactionId: transaction_id, } @@ -4280,6 +4335,7 @@ def delete_row( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -4310,28 +4366,28 @@ def decrement_row_column( min: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - .gsub('{column}', column) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end - if column.nil? + if column.nil? || column == '' raise Appwrite::Exception.new('Missing required parameter: "column"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + .gsub('{column}', column) + api_params = { value: value, min: min, @@ -4373,28 +4429,28 @@ def increment_row_column( max: nil, transaction_id: nil ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' - .gsub('{databaseId}', database_id) - .gsub('{tableId}', table_id) - .gsub('{rowId}', row_id) - .gsub('{column}', column) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if table_id.nil? + if table_id.nil? || table_id == '' raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if row_id.nil? + if row_id.nil? || row_id == '' raise Appwrite::Exception.new('Missing required parameter: "rowId"') end - if column.nil? + if column.nil? || column == '' raise Appwrite::Exception.new('Missing required parameter: "column"') end + api_path = '/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{rowId}', row_id) + .gsub('{column}', column) + api_params = { value: value, max: max, diff --git a/lib/appwrite/services/teams.rb b/lib/appwrite/services/teams.rb index 8e19b572..71a2bc7e 100644 --- a/lib/appwrite/services/teams.rb +++ b/lib/appwrite/services/teams.rb @@ -47,7 +47,7 @@ def list( # # @param [String] team_id Team 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 Team name. Max length: 128 chars. - # @param [Array] roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. + # @param [Array] roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long. # # @return [Team] def create( @@ -55,8 +55,6 @@ def create( name:, roles: nil ) - api_path = '/teams' - if team_id.nil? raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -65,6 +63,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/teams' + api_params = { teamId: team_id, name: name, @@ -94,13 +94,13 @@ def create( def get( team_id: ) - api_path = '/teams/{teamId}' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}' + .gsub('{teamId}', team_id) + api_params = {} api_headers = { @@ -127,10 +127,7 @@ def update_name( team_id:, name: ) - api_path = '/teams/{teamId}' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -138,6 +135,9 @@ def update_name( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/teams/{teamId}' + .gsub('{teamId}', team_id) + api_params = { name: name, } @@ -166,18 +166,19 @@ def update_name( def delete( team_id: ) - api_path = '/teams/{teamId}' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}' + .gsub('{teamId}', team_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -200,13 +201,13 @@ def list_installations( queries: nil, total: nil ) - api_path = '/teams/{teamId}/installations' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}/installations' + .gsub('{teamId}', team_id) + api_params = { queries: queries, total: total, @@ -241,10 +242,7 @@ def create_installation( app_id:, authorization_details: nil ) - api_path = '/teams/{teamId}/installations' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -252,6 +250,9 @@ def create_installation( raise Appwrite::Exception.new('Missing required parameter: "appId"') end + api_path = '/teams/{teamId}/installations' + .gsub('{teamId}', team_id) + api_params = { appId: app_id, authorizationDetails: authorization_details, @@ -283,18 +284,18 @@ 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? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/teams/{teamId}/installations/{installationId}' + .gsub('{teamId}', team_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -326,18 +327,18 @@ def update_installation( installation_id:, authorization_details: nil ) - api_path = '/teams/{teamId}/installations/{installationId}' - .gsub('{teamId}', team_id) - .gsub('{installationId}', installation_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/teams/{teamId}/installations/{installationId}' + .gsub('{teamId}', team_id) + .gsub('{installationId}', installation_id) + api_params = { authorizationDetails: authorization_details, } @@ -369,18 +370,18 @@ 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? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if installation_id.nil? + if installation_id.nil? || installation_id == '' raise Appwrite::Exception.new('Missing required parameter: "installationId"') end + api_path = '/teams/{teamId}/installations/{installationId}' + .gsub('{teamId}', team_id) + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -413,13 +414,13 @@ def list_memberships( search: nil, total: nil ) - api_path = '/teams/{teamId}/memberships' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}/memberships' + .gsub('{teamId}', team_id) + api_params = { queries: queries, search: search, @@ -482,10 +483,7 @@ def create_membership( name: nil, membership_id: nil ) - api_path = '/teams/{teamId}/memberships' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -493,6 +491,9 @@ def create_membership( raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/teams/{teamId}/memberships' + .gsub('{teamId}', team_id) + api_params = { email: email, userId: user_id, @@ -530,18 +531,18 @@ def get_membership( team_id:, membership_id: ) - api_path = '/teams/{teamId}/memberships/{membershipId}' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/teams/{teamId}/memberships/{membershipId}' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { @@ -573,15 +574,11 @@ def update_membership( membership_id:, roles: ) - api_path = '/teams/{teamId}/memberships/{membershipId}' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end @@ -589,6 +586,10 @@ def update_membership( raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/teams/{teamId}/memberships/{membershipId}' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = { roles: roles, } @@ -620,23 +621,24 @@ def delete_membership( team_id:, membership_id: ) - api_path = '/teams/{teamId}/memberships/{membershipId}' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end + api_path = '/teams/{teamId}/memberships/{membershipId}' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -667,15 +669,11 @@ def update_membership_status( user_id:, secret: ) - api_path = '/teams/{teamId}/memberships/{membershipId}/status' - .gsub('{teamId}', team_id) - .gsub('{membershipId}', membership_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end - if membership_id.nil? + if membership_id.nil? || membership_id == '' raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end @@ -687,6 +685,10 @@ def update_membership_status( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/teams/{teamId}/memberships/{membershipId}/status' + .gsub('{teamId}', team_id) + .gsub('{membershipId}', membership_id) + api_params = { userId: user_id, secret: secret, @@ -717,13 +719,13 @@ def update_membership_status( def get_prefs( team_id: ) - api_path = '/teams/{teamId}/prefs' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end + api_path = '/teams/{teamId}/prefs' + .gsub('{teamId}', team_id) + api_params = {} api_headers = { @@ -752,10 +754,7 @@ def update_prefs( team_id:, prefs: ) - api_path = '/teams/{teamId}/prefs' - .gsub('{teamId}', team_id) - - if team_id.nil? + if team_id.nil? || team_id == '' raise Appwrite::Exception.new('Missing required parameter: "teamId"') end @@ -763,6 +762,9 @@ def update_prefs( raise Appwrite::Exception.new('Missing required parameter: "prefs"') end + api_path = '/teams/{teamId}/prefs' + .gsub('{teamId}', team_id) + api_params = { prefs: prefs, } diff --git a/lib/appwrite/services/tokens.rb b/lib/appwrite/services/tokens.rb index 72ba9710..0e18e7b5 100644 --- a/lib/appwrite/services/tokens.rb +++ b/lib/appwrite/services/tokens.rb @@ -21,18 +21,18 @@ def list( queries: nil, total: nil ) - api_path = '/tokens/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/tokens/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { queries: queries, total: total, @@ -65,18 +65,18 @@ def create_file_token( file_id:, expire: nil ) - api_path = '/tokens/buckets/{bucketId}/files/{fileId}' - .gsub('{bucketId}', bucket_id) - .gsub('{fileId}', file_id) - - if bucket_id.nil? + if bucket_id.nil? || bucket_id == '' raise Appwrite::Exception.new('Missing required parameter: "bucketId"') end - if file_id.nil? + if file_id.nil? || file_id == '' raise Appwrite::Exception.new('Missing required parameter: "fileId"') end + api_path = '/tokens/buckets/{bucketId}/files/{fileId}' + .gsub('{bucketId}', bucket_id) + .gsub('{fileId}', file_id) + api_params = { expire: expire, } @@ -104,13 +104,13 @@ def create_file_token( def get( token_id: ) - api_path = '/tokens/{tokenId}' - .gsub('{tokenId}', token_id) - - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/tokens/{tokenId}' + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { @@ -138,13 +138,13 @@ def update( token_id:, expire: nil ) - api_path = '/tokens/{tokenId}' - .gsub('{tokenId}', token_id) - - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/tokens/{tokenId}' + .gsub('{tokenId}', token_id) + api_params = { expire: expire, } @@ -172,18 +172,19 @@ def update( def delete( token_id: ) - api_path = '/tokens/{tokenId}' - .gsub('{tokenId}', token_id) - - if token_id.nil? + if token_id.nil? || token_id == '' raise Appwrite::Exception.new('Missing required parameter: "tokenId"') end + api_path = '/tokens/{tokenId}' + .gsub('{tokenId}', token_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( diff --git a/lib/appwrite/services/users.rb b/lib/appwrite/services/users.rb index aefa1b2a..dbcf3e56 100644 --- a/lib/appwrite/services/users.rb +++ b/lib/appwrite/services/users.rb @@ -9,7 +9,7 @@ def initialize(client) # Get a list of all the project's users. You can use the query params to # filter your results. # - # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels, impersonator, accessedAt + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, passwordPwned, labels, impersonator, accessedAt # @param [String] search Search term to filter your list results. Max length: 256 chars. # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # @@ -57,12 +57,12 @@ def create( password: nil, name: nil ) - api_path = '/users' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users' + api_params = { userId: user_id, email: email, @@ -103,8 +103,6 @@ def create_argon2_user( password:, name: nil ) - api_path = '/users/argon2' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -117,6 +115,8 @@ def create_argon2_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/argon2' + api_params = { userId: user_id, email: email, @@ -156,8 +156,6 @@ def create_bcrypt_user( password:, name: nil ) - api_path = '/users/bcrypt' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -170,6 +168,8 @@ def create_bcrypt_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/bcrypt' + api_params = { userId: user_id, email: email, @@ -234,18 +234,19 @@ def list_identities( def delete_identity( identity_id: ) - api_path = '/users/identities/{identityId}' - .gsub('{identityId}', identity_id) - - if identity_id.nil? + if identity_id.nil? || identity_id == '' raise Appwrite::Exception.new('Missing required parameter: "identityId"') end + api_path = '/users/identities/{identityId}' + .gsub('{identityId}', identity_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -273,8 +274,6 @@ def create_md5_user( password:, name: nil ) - api_path = '/users/md5' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -287,6 +286,8 @@ def create_md5_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/md5' + api_params = { userId: user_id, email: email, @@ -326,8 +327,6 @@ def create_ph_pass_user( password:, name: nil ) - api_path = '/users/phpass' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -340,6 +339,8 @@ def create_ph_pass_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/phpass' + api_params = { userId: user_id, email: email, @@ -389,8 +390,6 @@ def create_scrypt_user( password_length:, name: nil ) - api_path = '/users/scrypt' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -423,6 +422,8 @@ def create_scrypt_user( raise Appwrite::Exception.new('Missing required parameter: "passwordLength"') end + api_path = '/users/scrypt' + api_params = { userId: user_id, email: email, @@ -474,8 +475,6 @@ def create_scrypt_modified_user( password_signer_key:, name: nil ) - api_path = '/users/scrypt-modified' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -500,6 +499,8 @@ def create_scrypt_modified_user( raise Appwrite::Exception.new('Missing required parameter: "passwordSignerKey"') end + api_path = '/users/scrypt-modified' + api_params = { userId: user_id, email: email, @@ -544,8 +545,6 @@ def create_sha_user( password_version: nil, name: nil ) - api_path = '/users/sha' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -558,6 +557,8 @@ def create_sha_user( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/sha' + api_params = { userId: user_id, email: email, @@ -589,13 +590,13 @@ def create_sha_user( def get( user_id: ) - api_path = '/users/{userId}' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -625,18 +626,19 @@ def get( def delete( user_id: ) - api_path = '/users/{userId}' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}' + .gsub('{userId}', user_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -657,10 +659,7 @@ def update_email( user_id:, email: ) - api_path = '/users/{userId}/email' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -668,6 +667,9 @@ def update_email( raise Appwrite::Exception.new('Missing required parameter: "email"') end + api_path = '/users/{userId}/email' + .gsub('{userId}', user_id) + api_params = { email: email, } @@ -691,7 +693,10 @@ def update_email( # impersonation headers are used, the request runs as the target user for API # behavior, while internal audit logs still attribute the action to the # original impersonator and store the impersonated target details only in - # internal audit payload data. + # internal audit payload data. Account endpoints are read-only while + # impersonating: they report the target's account, and anything that would + # change it is refused, so an impersonator cannot alter the target's + # credentials or delete their account. # # # @param [String] user_id User ID. @@ -702,10 +707,7 @@ def update_impersonator( user_id:, impersonator: ) - api_path = '/users/{userId}/impersonator' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -713,6 +715,9 @@ def update_impersonator( raise Appwrite::Exception.new('Missing required parameter: "impersonator"') end + api_path = '/users/{userId}/impersonator' + .gsub('{userId}', user_id) + api_params = { impersonator: impersonator, } @@ -746,13 +751,13 @@ def create_jwt( session_id: nil, duration: nil ) - api_path = '/users/{userId}/jwts' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/jwts' + .gsub('{userId}', user_id) + api_params = { sessionId: session_id, duration: duration, @@ -788,10 +793,7 @@ def update_labels( user_id:, labels: ) - api_path = '/users/{userId}/labels' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -799,6 +801,9 @@ def update_labels( raise Appwrite::Exception.new('Missing required parameter: "labels"') end + api_path = '/users/{userId}/labels' + .gsub('{userId}', user_id) + api_params = { labels: labels, } @@ -818,44 +823,6 @@ def update_labels( ) end - # Get the user activity logs list by its unique ID. - # - # @param [String] user_id User 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). Only supported methods are limit and offset - # @param [] total When set to false, the total count returned will be 0 and will not be calculated. - # - # @return [LogList] - def list_logs( - user_id:, - queries: nil, - total: nil - ) - api_path = '/users/{userId}/logs' - .gsub('{userId}', user_id) - - if user_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "userId"') - 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::LogList - ) - end - # Get the user membership list by its unique ID. # # @param [String] user_id User ID. @@ -870,13 +837,13 @@ def list_memberships( search: nil, total: nil ) - api_path = '/users/{userId}/memberships' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/memberships' + .gsub('{userId}', user_id) + api_params = { queries: queries, search: search, @@ -907,10 +874,7 @@ def update_mfa( user_id:, mfa: ) - api_path = '/users/{userId}/mfa' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -918,6 +882,9 @@ def update_mfa( raise Appwrite::Exception.new('Missing required parameter: "mfa"') end + api_path = '/users/{userId}/mfa' + .gsub('{userId}', user_id) + api_params = { mfa: mfa, } @@ -947,11 +914,7 @@ def delete_mfa_authenticator( user_id:, type: ) - api_path = '/users/{userId}/mfa/authenticators/{type}' - .gsub('{userId}', user_id) - .gsub('{type}', type) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -959,11 +922,16 @@ def delete_mfa_authenticator( raise Appwrite::Exception.new('Missing required parameter: "type"') end + api_path = '/users/{userId}/mfa/authenticators/{type}' + .gsub('{userId}', user_id) + .gsub('{type}', type) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -985,18 +953,18 @@ def get_mfa_challenge( user_id:, challenge_id: ) - api_path = '/users/{userId}/mfa/challenges/{challengeId}' - .gsub('{userId}', user_id) - .gsub('{challengeId}', challenge_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if challenge_id.nil? + if challenge_id.nil? || challenge_id == '' raise Appwrite::Exception.new('Missing required parameter: "challengeId"') end + api_path = '/users/{userId}/mfa/challenges/{challengeId}' + .gsub('{userId}', user_id) + .gsub('{challengeId}', challenge_id) + api_params = {} api_headers = { @@ -1021,13 +989,13 @@ def get_mfa_challenge( def list_mfa_factors( user_id: ) - api_path = '/users/{userId}/mfa/factors' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/factors' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1055,13 +1023,13 @@ def list_mfa_factors( def get_mfa_recovery_codes( user_id: ) - api_path = '/users/{userId}/mfa/recovery-codes' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/recovery-codes' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1089,13 +1057,13 @@ def get_mfa_recovery_codes( def update_mfa_recovery_codes( user_id: ) - api_path = '/users/{userId}/mfa/recovery-codes' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/recovery-codes' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1124,13 +1092,13 @@ def update_mfa_recovery_codes( def create_mfa_recovery_codes( user_id: ) - api_path = '/users/{userId}/mfa/recovery-codes' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/mfa/recovery-codes' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1158,10 +1126,7 @@ def update_name( user_id:, name: ) - api_path = '/users/{userId}/name' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1169,6 +1134,9 @@ def update_name( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/users/{userId}/name' + .gsub('{userId}', user_id) + api_params = { name: name, } @@ -1360,10 +1328,7 @@ def update_password( user_id:, password: ) - api_path = '/users/{userId}/password' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1371,6 +1336,9 @@ def update_password( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/users/{userId}/password' + .gsub('{userId}', user_id) + api_params = { password: password, } @@ -1400,10 +1368,7 @@ def update_phone( user_id:, number: ) - api_path = '/users/{userId}/phone' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1411,6 +1376,9 @@ def update_phone( raise Appwrite::Exception.new('Missing required parameter: "number"') end + api_path = '/users/{userId}/phone' + .gsub('{userId}', user_id) + api_params = { number: number, } @@ -1438,13 +1406,13 @@ def update_phone( def get_prefs( user_id: ) - api_path = '/users/{userId}/prefs' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/prefs' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1473,10 +1441,7 @@ def update_prefs( user_id:, prefs: ) - api_path = '/users/{userId}/prefs' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1484,6 +1449,9 @@ def update_prefs( raise Appwrite::Exception.new('Missing required parameter: "prefs"') end + api_path = '/users/{userId}/prefs' + .gsub('{userId}', user_id) + api_params = { prefs: prefs, } @@ -1513,13 +1481,13 @@ def list_sessions( user_id:, total: nil ) - api_path = '/users/{userId}/sessions' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/sessions' + .gsub('{userId}', user_id) + api_params = { total: total, } @@ -1551,13 +1519,13 @@ def list_sessions( def create_session( user_id: ) - api_path = '/users/{userId}/sessions' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/sessions' + .gsub('{userId}', user_id) + api_params = {} api_headers = { @@ -1583,18 +1551,19 @@ def create_session( def delete_sessions( user_id: ) - api_path = '/users/{userId}/sessions' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/sessions' + .gsub('{userId}', user_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1615,23 +1584,24 @@ def delete_session( user_id:, session_id: ) - api_path = '/users/{userId}/sessions/{sessionId}' - .gsub('{userId}', user_id) - .gsub('{sessionId}', session_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if session_id.nil? + if session_id.nil? || session_id == '' raise Appwrite::Exception.new('Missing required parameter: "sessionId"') end + api_path = '/users/{userId}/sessions/{sessionId}' + .gsub('{userId}', user_id) + .gsub('{sessionId}', session_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1653,10 +1623,7 @@ def update_status( user_id:, status: ) - api_path = '/users/{userId}/status' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1664,6 +1631,9 @@ def update_status( raise Appwrite::Exception.new('Missing required parameter: "status"') end + api_path = '/users/{userId}/status' + .gsub('{userId}', user_id) + api_params = { status: status, } @@ -1695,13 +1665,13 @@ def list_targets( queries: nil, total: nil ) - api_path = '/users/{userId}/targets' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/targets' + .gsub('{userId}', user_id) + api_params = { queries: queries, total: total, @@ -1739,10 +1709,7 @@ def create_target( provider_id: nil, name: nil ) - api_path = '/users/{userId}/targets' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1758,6 +1725,9 @@ def create_target( raise Appwrite::Exception.new('Missing required parameter: "identifier"') end + api_path = '/users/{userId}/targets' + .gsub('{userId}', user_id) + api_params = { targetId: target_id, providerType: provider_type, @@ -1791,18 +1761,18 @@ def get_target( user_id:, target_id: ) - api_path = '/users/{userId}/targets/{targetId}' - .gsub('{userId}', user_id) - .gsub('{targetId}', target_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if target_id.nil? + if target_id.nil? || target_id == '' raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/users/{userId}/targets/{targetId}' + .gsub('{userId}', user_id) + .gsub('{targetId}', target_id) + api_params = {} api_headers = { @@ -1835,18 +1805,18 @@ def update_target( provider_id: nil, name: nil ) - api_path = '/users/{userId}/targets/{targetId}' - .gsub('{userId}', user_id) - .gsub('{targetId}', target_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if target_id.nil? + if target_id.nil? || target_id == '' raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/users/{userId}/targets/{targetId}' + .gsub('{userId}', user_id) + .gsub('{targetId}', target_id) + api_params = { identifier: identifier, providerId: provider_id, @@ -1878,23 +1848,24 @@ def delete_target( user_id:, target_id: ) - api_path = '/users/{userId}/targets/{targetId}' - .gsub('{userId}', user_id) - .gsub('{targetId}', target_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end - if target_id.nil? + if target_id.nil? || target_id == '' raise Appwrite::Exception.new('Missing required parameter: "targetId"') end + api_path = '/users/{userId}/targets/{targetId}' + .gsub('{userId}', user_id) + .gsub('{targetId}', target_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1921,13 +1892,13 @@ def create_token( length: nil, expire: nil ) - api_path = '/users/{userId}/tokens' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/tokens' + .gsub('{userId}', user_id) + api_params = { length: length, expire: expire, @@ -1958,10 +1929,7 @@ def update_email_verification( user_id:, email_verification: ) - api_path = '/users/{userId}/verification' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1969,6 +1937,9 @@ def update_email_verification( raise Appwrite::Exception.new('Missing required parameter: "emailVerification"') end + api_path = '/users/{userId}/verification' + .gsub('{userId}', user_id) + api_params = { emailVerification: email_verification, } @@ -1998,10 +1969,7 @@ def update_phone_verification( user_id:, phone_verification: ) - api_path = '/users/{userId}/verification/phone' - .gsub('{userId}', user_id) - - if user_id.nil? + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -2009,6 +1977,9 @@ def update_phone_verification( raise Appwrite::Exception.new('Missing required parameter: "phoneVerification"') end + api_path = '/users/{userId}/verification/phone' + .gsub('{userId}', user_id) + api_params = { phoneVerification: phone_verification, } diff --git a/lib/appwrite/services/vectors_db.rb b/lib/appwrite/services/vectors_db.rb index 5d8fe64e..a3440518 100644 --- a/lib/appwrite/services/vectors_db.rb +++ b/lib/appwrite/services/vectors_db.rb @@ -57,8 +57,6 @@ def create( replicas: nil, sync_mode: nil ) - api_path = '/vectorsdb' - if database_id.nil? raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -67,6 +65,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/vectorsdb' + api_params = { databaseId: database_id, name: name, @@ -92,8 +92,8 @@ def create( 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. + # Each specification reports its resource limits, its own prices and overage + # rates, and whether it is enabled for the organization. # # # @return [DedicatedDatabaseSpecificationList] @@ -184,13 +184,13 @@ def create_transaction( def get_transaction( transaction_id: ) - api_path = '/vectorsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { @@ -219,13 +219,13 @@ def update_transaction( commit: nil, rollback: nil ) - api_path = '/vectorsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = { commit: commit, rollback: rollback, @@ -254,18 +254,19 @@ def update_transaction( def delete_transaction( transaction_id: ) - api_path = '/vectorsdb/transactions/{transactionId}' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}' + .gsub('{transactionId}', transaction_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -286,13 +287,13 @@ def create_operations( transaction_id:, operations: nil ) - api_path = '/vectorsdb/transactions/{transactionId}/operations' - .gsub('{transactionId}', transaction_id) - - if transaction_id.nil? + if transaction_id.nil? || transaction_id == '' raise Appwrite::Exception.new('Missing required parameter: "transactionId"') end + api_path = '/vectorsdb/transactions/{transactionId}/operations' + .gsub('{transactionId}', transaction_id) + api_params = { operations: operations, } @@ -321,13 +322,13 @@ def create_operations( def get( database_id: ) - api_path = '/vectorsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -362,10 +363,7 @@ def update( replicas: nil, sync_mode: nil ) - api_path = '/vectorsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -373,6 +371,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/vectorsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = { name: name, enabled: enabled, @@ -405,18 +406,19 @@ def update( def delete( database_id: ) - api_path = '/vectorsdb/{databaseId}' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -442,13 +444,13 @@ def list_collections( search: nil, total: nil ) - api_path = '/vectorsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { queries: queries, search: search, @@ -492,10 +494,7 @@ def create_collection( document_security: nil, enabled: nil ) - api_path = '/vectorsdb/{databaseId}/collections' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end @@ -511,6 +510,9 @@ def create_collection( raise Appwrite::Exception.new('Missing required parameter: "dimension"') end + api_path = '/vectorsdb/{databaseId}/collections' + .gsub('{databaseId}', database_id) + api_params = { collectionId: collection_id, name: name, @@ -546,18 +548,18 @@ def get_collection( database_id:, collection_id: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { @@ -594,15 +596,11 @@ def update_collection( document_security: nil, enabled: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -610,6 +608,10 @@ def update_collection( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { name: name, dimension: dimension, @@ -644,23 +646,24 @@ def delete_collection( database_id:, collection_id: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -690,18 +693,18 @@ def list_documents( total: nil, ttl: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -744,15 +747,11 @@ def create_document( permissions: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -764,6 +763,10 @@ def create_document( raise Appwrite::Exception.new('Missing required parameter: "data"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documentId: document_id, data: data, @@ -803,15 +806,11 @@ def create_documents( documents:, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -819,6 +818,10 @@ def create_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -857,15 +860,11 @@ def upsert_documents( documents:, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -873,6 +872,10 @@ def upsert_documents( raise Appwrite::Exception.new('Missing required parameter: "documents"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { documents: documents, transactionId: transaction_id, @@ -911,18 +914,18 @@ def update_documents( queries: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { data: data, queries: queries, @@ -959,18 +962,18 @@ def delete_documents( queries: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1013,18 +1016,18 @@ def create_query( total: nil, ttl: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/query' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/query' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1064,23 +1067,23 @@ def get_document( queries: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { queries: queries, transactionId: transaction_id, @@ -1121,23 +1124,23 @@ def upsert_document( permissions: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1178,23 +1181,23 @@ def update_document( permissions: nil, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { data: data, permissions: permissions, @@ -1230,23 +1233,23 @@ def delete_document( document_id:, transaction_id: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{documentId}', document_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if document_id.nil? + if document_id.nil? || document_id == '' raise Appwrite::Exception.new('Missing required parameter: "documentId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/documents/{documentId}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{documentId}', document_id) + api_params = { transactionId: transaction_id, } @@ -1254,6 +1257,7 @@ def delete_document( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1278,18 +1282,18 @@ def list_indexes( queries: nil, total: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { queries: queries, total: total, @@ -1331,15 +1335,11 @@ def create_index( orders: nil, lengths: nil ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end @@ -1355,6 +1355,10 @@ def create_index( raise Appwrite::Exception.new('Missing required parameter: "attributes"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + api_params = { key: key, type: type, @@ -1390,23 +1394,23 @@ def get_index( collection_id:, key: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { @@ -1435,28 +1439,29 @@ def delete_index( collection_id:, key: ) - api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' - .gsub('{databaseId}', database_id) - .gsub('{collectionId}', collection_id) - .gsub('{key}', key) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if collection_id.nil? + if collection_id.nil? || collection_id == '' raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if key.nil? + if key.nil? || key == '' raise Appwrite::Exception.new('Missing required parameter: "key"') end + api_path = '/vectorsdb/{databaseId}/collections/{collectionId}/indexes/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1485,13 +1490,13 @@ def create_failover( database_id:, target_replica_id: nil ) - api_path = '/vectorsdb/{databaseId}/failovers' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/failovers' + .gsub('{databaseId}', database_id) + api_params = { targetReplicaId: target_replica_id, } @@ -1528,13 +1533,13 @@ def list_operations( limit: nil, offset: nil ) - api_path = '/vectorsdb/{databaseId}/operations' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/operations' + .gsub('{databaseId}', database_id) + api_params = { status: status, limit: limit, @@ -1564,13 +1569,13 @@ def list_operations( def get_replicas( database_id: ) - api_path = '/vectorsdb/{databaseId}/replicas' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/replicas' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { @@ -1597,13 +1602,13 @@ def get_replicas( def get_status( database_id: ) - api_path = '/vectorsdb/{databaseId}/status' - .gsub('{databaseId}', database_id) - - if database_id.nil? + if database_id.nil? || database_id == '' raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end + api_path = '/vectorsdb/{databaseId}/status' + .gsub('{databaseId}', database_id) + api_params = {} api_headers = { diff --git a/lib/appwrite/services/waf.rb b/lib/appwrite/services/waf.rb index 949dd1ee..24a3b0f7 100644 --- a/lib/appwrite/services/waf.rb +++ b/lib/appwrite/services/waf.rb @@ -137,7 +137,7 @@ def update_bypass_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -284,7 +284,7 @@ def update_challenge_rule( difficulty: nil, ttl: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -415,7 +415,7 @@ def update_deny_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -578,7 +578,7 @@ def update_rate_limit_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -728,7 +728,7 @@ def update_redirect_rule( enabled: nil, conditions: nil ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -771,7 +771,7 @@ def update_redirect_rule( def get_rule( rule_id: ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end @@ -833,7 +833,7 @@ def get_rule( def delete_rule( rule_id: ) - if rule_id.nil? + if rule_id.nil? || rule_id == '' raise Appwrite::Exception.new('Missing required parameter: "ruleId"') end diff --git a/lib/appwrite/services/webhooks.rb b/lib/appwrite/services/webhooks.rb index 893cc08e..8f1a17cd 100644 --- a/lib/appwrite/services/webhooks.rb +++ b/lib/appwrite/services/webhooks.rb @@ -47,8 +47,8 @@ def list( # @param [Array] events Events list. Maximum of 100 events are allowed. # @param [] enabled Enable or disable a webhook. # @param [] tls Certificate verification, false for disabled or true for enabled. - # @param [String] auth_username Webhook HTTP user. Max length: 256 chars. - # @param [String] auth_password Webhook HTTP password. Max length: 256 chars. + # @param [String] auth_username Webhook HTTP user. Max length: 255 chars. + # @param [String] auth_password Webhook HTTP password. Max length: 2048 chars. # @param [String] secret Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. # # @return [Webhook] @@ -63,8 +63,6 @@ def create( auth_password: nil, secret: nil ) - api_path = '/webhooks' - if webhook_id.nil? raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end @@ -81,6 +79,8 @@ def create( raise Appwrite::Exception.new('Missing required parameter: "events"') end + api_path = '/webhooks' + api_params = { webhookId: webhook_id, url: url, @@ -117,13 +117,13 @@ def create( def get( webhook_id: ) - api_path = '/webhooks/{webhookId}' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end + api_path = '/webhooks/{webhookId}' + .gsub('{webhookId}', webhook_id) + api_params = {} api_headers = { @@ -149,8 +149,8 @@ def get( # @param [Array] events Events list. Maximum of 100 events are allowed. # @param [] enabled Enable or disable a webhook. # @param [] tls Certificate verification, false for disabled or true for enabled. - # @param [String] auth_username Webhook HTTP user. Max length: 256 chars. - # @param [String] auth_password Webhook HTTP password. Max length: 256 chars. + # @param [String] auth_username Webhook HTTP user. Max length: 255 chars. + # @param [String] auth_password Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. # # @return [Webhook] def update( @@ -163,10 +163,7 @@ def update( auth_username: nil, auth_password: nil ) - api_path = '/webhooks/{webhookId}' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end @@ -182,6 +179,9 @@ def update( raise Appwrite::Exception.new('Missing required parameter: "events"') end + api_path = '/webhooks/{webhookId}' + .gsub('{webhookId}', webhook_id) + api_params = { name: name, url: url, @@ -216,18 +216,19 @@ def update( def delete( webhook_id: ) - api_path = '/webhooks/{webhookId}' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end + api_path = '/webhooks/{webhookId}' + .gsub('{webhookId}', webhook_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -250,13 +251,13 @@ def update_secret( webhook_id:, secret: nil ) - api_path = '/webhooks/{webhookId}/secret' - .gsub('{webhookId}', webhook_id) - - if webhook_id.nil? + if webhook_id.nil? || webhook_id == '' raise Appwrite::Exception.new('Missing required parameter: "webhookId"') end + api_path = '/webhooks/{webhookId}/secret' + .gsub('{webhookId}', webhook_id) + api_params = { secret: secret, } diff --git a/lib/appwrite/topic.rb b/lib/appwrite/topic.rb new file mode 100644 index 00000000..b9f215bb --- /dev/null +++ b/lib/appwrite/topic.rb @@ -0,0 +1,53 @@ +module Appwrite + # Helper to build MQTT topics for `Push`, level by level. + # + # Topic.path(['user', user_id, 'notification']) # "user/123/notification" + # Topic.path(['org', org_id]).path(['logs']) # "org/42/logs" + class Topic + private_class_method :new + + # Start a topic with the given levels, e.g. `Topic.path(['user', user_id])`. + def self.path(levels) + new([]).path(levels) + end + + def initialize(levels) + @levels = levels.freeze + end + + # Append the given levels. + def path(levels) + self.class.send(:new, @levels + self.class.send(:levels_of, levels)) + end + + def to_s + @levels.join('/') + end + + # Validate the levels passed to `path`: a non-empty array of non-empty strings, none holding + # the level separator `/` or the MQTT wildcards `+` and `#`. + def self.levels_of(levels) + raise ArgumentError, "path() expects an array, e.g. path(['user'])" unless levels.is_a?(Array) + raise ArgumentError, 'path() needs at least one level' if levels.empty? + + levels.each_with_index do |level, index| + unless level.is_a?(String) + type = level.nil? ? 'null' : level.class.name + raise ArgumentError, "level at index #{index} must be a string, got #{type}" + end + raise ArgumentError, "empty level at index #{index}" if level.empty? + + if level.include?('/') + parts = level.split('/', -1).map { |part| "'#{part}'" }.join(', ') + raise ArgumentError, "\"#{level}\" contains \"/\", split it: path([#{parts}])" + end + raise ArgumentError, "\"#{level}\" contains \"+\", not allowed in a topic" if level.include?('+') + raise ArgumentError, "\"#{level}\" contains \"#\", not allowed in a topic" if level.include?('#') + raise ArgumentError, "level at index #{index} contains a NUL character" if level.include?("\0") + end + + levels.dup + end + private_class_method :levels_of + end +end