From 21769f2cf399d71b2c505697348c6c03d914f775 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 12 Oct 2026 16:52:04 +0100 Subject: [PATCH] chore: update Ruby SDK to 29.0.0 --- CHANGELOG.md | 35 + README.md | 4 +- appwrite.gemspec | 2 +- .../account/create-email-password-session.md | 3 +- .../account/create-email-verification-otp.md | 16 + .../account/create-id-token-session.md | 22 + docs/examples/account/create-passkey-token.md | 14 + docs/examples/account/create-passkey.md | 17 + docs/examples/account/create-recovery-otp.md | 17 + docs/examples/account/delete-passkey.md | 16 + docs/examples/account/delete-sessions.md | 4 +- docs/examples/account/get-passkey.md | 16 + .../{list-logs.md => list-passkeys.md} | 2 +- docs/examples/account/list-sessions.md | 4 +- .../account/update-email-verification-otp.md | 17 + docs/examples/account/update-passkey-token.md | 17 + .../account/update-passkey-verification.md | 17 + docs/examples/account/update-passkey.md | 17 + docs/examples/account/update-recovery-otp.md | 18 + docs/examples/avatars/delete-photo.md | 14 + docs/examples/avatars/get-screenshot.md | 3 +- docs/examples/avatars/update-photo.md | 16 + docs/examples/databases/create-documents.md | 11 +- docs/examples/databases/create-index.md | 2 +- docs/examples/databases/delete-documents.md | 2 +- docs/examples/databases/list-transactions.md | 3 +- 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 +- .../examples/documentsdb/list-transactions.md | 3 +- docs/examples/documentsdb/upsert-documents.md | 11 +- .../domains/create-preset-google-workspace.md | 16 + .../examples/domains/create-preset-i-cloud.md | 16 + .../examples/domains/create-preset-mailgun.md | 16 + .../examples/domains/create-preset-outlook.md | 16 + .../domains/create-preset-proton-mail.md | 16 + docs/examples/domains/create-preset-zoho.md | 16 + docs/examples/domains/create-record-a.md | 20 + docs/examples/domains/create-record-aaaa.md | 20 + docs/examples/domains/create-record-alias.md | 20 + docs/examples/domains/create-record-caa.md | 20 + docs/examples/domains/create-record-cname.md | 20 + docs/examples/domains/create-record-https.md | 20 + docs/examples/domains/create-record-mx.md | 21 + docs/examples/domains/create-record-ns.md | 20 + docs/examples/domains/create-record-srv.md | 23 + docs/examples/domains/create-record-txt.md | 20 + docs/examples/domains/create.md | 17 + docs/examples/domains/delete-record.md | 17 + docs/examples/domains/delete.md | 16 + .../domains/get-preset-google-workspace.md | 16 + docs/examples/domains/get-preset-i-cloud.md | 16 + docs/examples/domains/get-preset-mailgun.md | 16 + docs/examples/domains/get-preset-outlook.md | 16 + .../domains/get-preset-proton-mail.md | 16 + docs/examples/domains/get-preset-zoho.md | 16 + docs/examples/domains/get-price.md | 19 + docs/examples/domains/get-record.md | 17 + docs/examples/domains/get-transfer-status.md | 16 + docs/examples/domains/get-zone.md | 16 + docs/examples/domains/get.md | 16 + docs/examples/domains/list-prices.md | 19 + docs/examples/domains/list-records.md | 17 + docs/examples/domains/list.md | 17 + docs/examples/domains/update-nameservers.md | 17 + docs/examples/domains/update-record-a.md | 21 + docs/examples/domains/update-record-aaaa.md | 21 + docs/examples/domains/update-record-alias.md | 21 + docs/examples/domains/update-record-caa.md | 21 + docs/examples/domains/update-record-cname.md | 21 + docs/examples/domains/update-record-https.md | 21 + docs/examples/domains/update-record-mx.md | 22 + docs/examples/domains/update-record-ns.md | 21 + docs/examples/domains/update-record-srv.md | 24 + docs/examples/domains/update-record-txt.md | 21 + docs/examples/domains/update-team.md | 17 + docs/examples/domains/update-zone.md | 17 + docs/examples/domains/verify-nameservers.md | 16 + .../embeddings/create-text-embeddings.md | 2 +- docs/examples/functions/list-runtimes.md | 4 +- .../examples/functions/list-specifications.md | 3 +- docs/examples/graphql/mutation.md | 4 +- docs/examples/graphql/query.md | 4 +- docs/examples/locale/list-codes.md | 4 +- docs/examples/locale/list-continents.md | 4 +- docs/examples/locale/list-countries-eu.md | 4 +- docs/examples/locale/list-countries-phones.md | 4 +- docs/examples/locale/list-countries.md | 4 +- docs/examples/locale/list-currencies.md | 4 +- docs/examples/locale/list-languages.md | 4 +- .../messaging/create-appwrite-provider.md | 20 + docs/examples/messaging/create-email.md | 2 + docs/examples/messaging/create-push.md | 3 +- docs/examples/messaging/create-topic.md | 4 +- .../messaging/create-twilio-provider.md | 2 +- .../messaging/update-appwrite-provider.md | 20 + docs/examples/messaging/update-email.md | 14 +- docs/examples/messaging/update-push.md | 7 +- docs/examples/messaging/update-sms.md | 2 +- docs/examples/messaging/update-topic.md | 4 +- 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/introspect.md | 19 + 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 +- ...key.md => create-ephemeral-project-key.md} | 9 +- .../{get-key.md => delete-project-key.md} | 3 +- .../{delete-key.md => get-project-key.md} | 3 +- .../{list-keys.md => list-project-keys.md} | 3 +- .../{update-key.md => update-project-key.md} | 5 +- .../project/create-android-platform.md | 3 +- docs/examples/project/create-ephemeral-key.md | 2 +- docs/examples/project/create-smtp-test.md | 2 +- .../project/update-android-platform.md | 3 +- docs/examples/project/update-key.md | 2 +- docs/examples/project/update-labels.md | 2 +- .../examples/project/update-o-auth-2-apple.md | 4 +- .../project/update-o-auth-2-auth-0.md | 2 + .../project/update-o-auth-2-discord.md | 2 + .../project/update-o-auth-2-git-hub.md | 2 + .../project/update-o-auth-2-google.md | 4 +- .../examples/project/update-o-auth-2-kakao.md | 20 + .../project/update-o-auth-2-microsoft.md | 2 + docs/examples/project/update-o-auth-2-okta.md | 2 + .../project/update-o-auth-2-salesforce.md | 2 + .../project/update-o-auth-2-tik-tok.md | 18 + .../project/update-o-auth-2-webflow.md | 18 + docs/examples/project/update-o-auth-2-zoho.md | 2 + .../examples/project/update-passkey-policy.md | 16 + .../project/update-password-pwned-policy.md | 18 + .../update-password-rotation-policy.md | 17 + docs/examples/sites/list-frameworks.md | 4 +- docs/examples/sites/list-specifications.md | 3 +- 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/list-transactions.md | 3 +- docs/examples/tablesdb/upsert-rows.md | 11 +- docs/examples/teams/create-membership.md | 3 +- docs/examples/teams/update-membership.md | 2 +- docs/examples/users/delete-passkey.md | 17 + docs/examples/users/get-passkey.md | 17 + .../users/{list-logs.md => list-passkeys.md} | 2 +- docs/examples/users/update-labels.md | 2 +- docs/examples/users/update-passkey.md | 18 + 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/list-transactions.md | 3 +- docs/examples/vectorsdb/update-collection.md | 2 +- docs/examples/vectorsdb/upsert-documents.md | 15 +- docs/examples/waf/create-bypass-rule.md | 23 + docs/examples/waf/create-challenge-rule.md | 26 + docs/examples/waf/create-deny-rule.md | 23 + docs/examples/waf/create-rate-limit-rule.md | 28 + docs/examples/waf/create-redirect-rule.md | 25 + docs/examples/waf/delete-rule.md | 16 + docs/examples/waf/get-rule.md | 16 + docs/examples/waf/list-rules.md | 18 + docs/examples/waf/update-bypass-rule.md | 23 + docs/examples/waf/update-challenge-rule.md | 26 + docs/examples/waf/update-deny-rule.md | 23 + docs/examples/waf/update-rate-limit-rule.md | 27 + docs/examples/waf/update-redirect-rule.md | 25 + docs/examples/webhooks/create.md | 2 +- docs/examples/webhooks/update.md | 2 +- lib/appwrite.rb | 61 +- lib/appwrite/client.rb | 54 +- lib/appwrite/enums/billing_plan_group.rb | 3 +- lib/appwrite/enums/build_runtime.rb | 2 + .../enums/domain_registration_type.rb | 10 + .../enums/domain_transfer_status_enum.rb | 14 + lib/appwrite/enums/framework.rb | 1 + lib/appwrite/enums/id_token_provider.rb | 8 + lib/appwrite/enums/image_gravity.rb | 1 + lib/appwrite/enums/o_auth2_auth0_prompt.rb | 9 + lib/appwrite/enums/o_auth2_discord_prompt.rb | 8 + lib/appwrite/enums/o_auth2_github_prompt.rb | 7 + lib/appwrite/enums/o_auth2_kakao_prompt.rb | 10 + .../enums/o_auth2_microsoft_prompt.rb | 10 + lib/appwrite/enums/o_auth2_okta_prompt.rb | 9 + .../enums/o_auth2_salesforce_prompt.rb | 8 + lib/appwrite/enums/o_auth2_zoho_prompt.rb | 7 + lib/appwrite/enums/o_auth_provider.rb | 3 + lib/appwrite/enums/organization_key_scopes.rb | 22 - lib/appwrite/enums/project_auth_method_id.rb | 1 + .../enums/project_email_template_id.rb | 2 + lib/appwrite/enums/project_key_scopes.rb | 4 + .../enums/project_o_auth2_auth0_prompt.rb | 9 + .../enums/project_o_auth2_discord_prompt.rb | 8 + .../enums/project_o_auth2_git_hub_prompt.rb | 7 + .../enums/project_o_auth2_kakao_prompt.rb | 10 + .../enums/project_o_auth2_microsoft_prompt.rb | 10 + .../enums/project_o_auth2_okta_prompt.rb | 9 + .../project_o_auth2_salesforce_prompt.rb | 8 + .../enums/project_o_auth2_zoho_prompt.rb | 7 + .../enums/project_o_auth_provider_id.rb | 3 + lib/appwrite/enums/project_policy_id.rb | 3 + .../proxy_rule_deployment_resource_type.rb | 1 + lib/appwrite/enums/runtime.rb | 2 + lib/appwrite/enums/waf_rule_action.rb | 11 + lib/appwrite/models/account.rb | 143 + 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 | 25 +- .../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 | 16 + .../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 | 21 + .../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/dns_record.rb | 83 + lib/appwrite/models/dns_records_list.rb | 33 + lib/appwrite/models/document.rb | 1 + lib/appwrite/models/document_list.rb | 1 + lib/appwrite/models/domain.rb | 109 + lib/appwrite/models/domain_price.rb | 63 + lib/appwrite/models/domain_prices_list.rb | 33 + lib/appwrite/models/domain_transfer_status.rb | 59 + lib/appwrite/models/domains_list.rb | 33 + 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 | 12 +- 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/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 | 17 +- lib/appwrite/models/o_auth2_appwrite.rb | 1 + lib/appwrite/models/o_auth2_auth0.rb | 22 + 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 | 27 +- 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 | 26 +- lib/appwrite/models/o_auth2_gitlab.rb | 1 + lib/appwrite/models/o_auth2_google.rb | 17 +- lib/appwrite/models/o_auth2_hugging_face.rb | 1 + lib/appwrite/models/o_auth2_kakao.rb | 65 + 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 | 23 + lib/appwrite/models/o_auth2_notion.rb | 1 + lib/appwrite/models/o_auth2_oidc.rb | 11 +- lib/appwrite/models/o_auth2_okta.rb | 22 + 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 | 27 +- 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_tik_tok.rb | 43 + lib/appwrite/models/o_auth2_tradeshift.rb | 1 + lib/appwrite/models/o_auth2_twitch.rb | 1 + lib/appwrite/models/o_auth2_webflow.rb | 43 + 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 | 26 +- 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 | 83 + 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 + .../models/{dev_key.rb => passkey.rb} | 26 +- lib/appwrite/models/passkey_challenge.rb | 48 + lib/appwrite/models/passkey_list.rb | 33 + lib/appwrite/models/phone.rb | 1 + lib/appwrite/models/phone_list.rb | 1 + lib/appwrite/models/platform_android.rb | 12 +- 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 | 38 + .../models/policy_password_dictionary.rb | 1 + .../models/policy_password_history.rb | 1 + .../models/policy_password_personal_data.rb | 1 + lib/appwrite/models/policy_password_pwned.rb | 43 + .../models/policy_password_rotation.rb | 38 + .../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 | 40 +- lib/appwrite/models/project_auth_method.rb | 2 + 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 | 2 + 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 | 53 + lib/appwrite/models/topic.rb | 17 +- 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 | 6 + 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/waf_rule_bypass.rb | 111 + lib/appwrite/models/waf_rule_challenge.rb | 126 + lib/appwrite/models/waf_rule_deny.rb | 111 + .../models/{log_list.rb => waf_rule_list.rb} | 15 +- lib/appwrite/models/waf_rule_rate_limit.rb | 136 + lib/appwrite/models/waf_rule_redirect.rb | 121 + lib/appwrite/models/webhook.rb | 1 + lib/appwrite/models/webhook_list.rb | 1 + lib/appwrite/services/account.rb | 876 +++++-- lib/appwrite/services/activities.rb | 8 +- lib/appwrite/services/advisor.rb | 37 +- lib/appwrite/services/apps.rb | 178 +- lib/appwrite/services/avatars.rb | 113 +- lib/appwrite/services/backups.rb | 60 +- lib/appwrite/services/databases.rb | 951 +++---- lib/appwrite/services/documents_db.rb | 390 +-- lib/appwrite/services/domains.rb | 2318 +++++++++++++++++ lib/appwrite/services/embeddings.rb | 4 +- lib/appwrite/services/functions.rb | 235 +- lib/appwrite/services/graphql.rb | 8 +- lib/appwrite/services/locale.rb | 63 +- lib/appwrite/services/messaging.rb | 480 ++-- lib/appwrite/services/mongo.rb | 262 +- lib/appwrite/services/mysql.rb | 286 +- lib/appwrite/services/oauth2.rb | 99 +- lib/appwrite/services/organization.rb | 476 ++-- lib/appwrite/services/postgresql.rb | 314 +-- lib/appwrite/services/presences.rb | 33 +- lib/appwrite/services/project.rb | 584 ++++- lib/appwrite/services/proxy.rb | 47 +- lib/appwrite/services/sites.rb | 226 +- lib/appwrite/services/storage.rb | 121 +- lib/appwrite/services/tables_db.rb | 1151 ++++---- lib/appwrite/services/teams.rb | 167 +- lib/appwrite/services/tokens.rb | 49 +- lib/appwrite/services/users.rb | 527 ++-- lib/appwrite/services/vectors_db.rb | 362 +-- lib/appwrite/services/waf.rb | 859 ++++++ lib/appwrite/services/webhooks.rb | 45 +- lib/appwrite/topic.rb | 102 + 566 files changed, 12589 insertions(+), 3845 deletions(-) create mode 100644 docs/examples/account/create-email-verification-otp.md create mode 100644 docs/examples/account/create-id-token-session.md create mode 100644 docs/examples/account/create-passkey-token.md create mode 100644 docs/examples/account/create-passkey.md create mode 100644 docs/examples/account/create-recovery-otp.md create mode 100644 docs/examples/account/delete-passkey.md create mode 100644 docs/examples/account/get-passkey.md rename docs/examples/account/{list-logs.md => list-passkeys.md} (91%) create mode 100644 docs/examples/account/update-email-verification-otp.md create mode 100644 docs/examples/account/update-passkey-token.md create mode 100644 docs/examples/account/update-passkey-verification.md create mode 100644 docs/examples/account/update-passkey.md create mode 100644 docs/examples/account/update-recovery-otp.md create mode 100644 docs/examples/avatars/delete-photo.md create mode 100644 docs/examples/avatars/update-photo.md create mode 100644 docs/examples/domains/create-preset-google-workspace.md create mode 100644 docs/examples/domains/create-preset-i-cloud.md create mode 100644 docs/examples/domains/create-preset-mailgun.md create mode 100644 docs/examples/domains/create-preset-outlook.md create mode 100644 docs/examples/domains/create-preset-proton-mail.md create mode 100644 docs/examples/domains/create-preset-zoho.md create mode 100644 docs/examples/domains/create-record-a.md create mode 100644 docs/examples/domains/create-record-aaaa.md create mode 100644 docs/examples/domains/create-record-alias.md create mode 100644 docs/examples/domains/create-record-caa.md create mode 100644 docs/examples/domains/create-record-cname.md create mode 100644 docs/examples/domains/create-record-https.md create mode 100644 docs/examples/domains/create-record-mx.md create mode 100644 docs/examples/domains/create-record-ns.md create mode 100644 docs/examples/domains/create-record-srv.md create mode 100644 docs/examples/domains/create-record-txt.md create mode 100644 docs/examples/domains/create.md create mode 100644 docs/examples/domains/delete-record.md create mode 100644 docs/examples/domains/delete.md create mode 100644 docs/examples/domains/get-preset-google-workspace.md create mode 100644 docs/examples/domains/get-preset-i-cloud.md create mode 100644 docs/examples/domains/get-preset-mailgun.md create mode 100644 docs/examples/domains/get-preset-outlook.md create mode 100644 docs/examples/domains/get-preset-proton-mail.md create mode 100644 docs/examples/domains/get-preset-zoho.md create mode 100644 docs/examples/domains/get-price.md create mode 100644 docs/examples/domains/get-record.md create mode 100644 docs/examples/domains/get-transfer-status.md create mode 100644 docs/examples/domains/get-zone.md create mode 100644 docs/examples/domains/get.md create mode 100644 docs/examples/domains/list-prices.md create mode 100644 docs/examples/domains/list-records.md create mode 100644 docs/examples/domains/list.md create mode 100644 docs/examples/domains/update-nameservers.md create mode 100644 docs/examples/domains/update-record-a.md create mode 100644 docs/examples/domains/update-record-aaaa.md create mode 100644 docs/examples/domains/update-record-alias.md create mode 100644 docs/examples/domains/update-record-caa.md create mode 100644 docs/examples/domains/update-record-cname.md create mode 100644 docs/examples/domains/update-record-https.md create mode 100644 docs/examples/domains/update-record-mx.md create mode 100644 docs/examples/domains/update-record-ns.md create mode 100644 docs/examples/domains/update-record-srv.md create mode 100644 docs/examples/domains/update-record-txt.md create mode 100644 docs/examples/domains/update-team.md create mode 100644 docs/examples/domains/update-zone.md create mode 100644 docs/examples/domains/verify-nameservers.md create mode 100644 docs/examples/messaging/create-appwrite-provider.md create mode 100644 docs/examples/messaging/update-appwrite-provider.md create mode 100644 docs/examples/oauth2/introspect.md rename docs/examples/organization/{create-key.md => create-ephemeral-project-key.md} (63%) rename docs/examples/organization/{get-key.md => delete-project-key.md} (81%) rename docs/examples/organization/{delete-key.md => get-project-key.md} (82%) rename docs/examples/organization/{list-keys.md => list-project-keys.md} (83%) rename docs/examples/organization/{update-key.md => update-project-key.md} (78%) create mode 100644 docs/examples/project/update-o-auth-2-kakao.md create mode 100644 docs/examples/project/update-o-auth-2-tik-tok.md create mode 100644 docs/examples/project/update-o-auth-2-webflow.md create mode 100644 docs/examples/project/update-passkey-policy.md create mode 100644 docs/examples/project/update-password-pwned-policy.md create mode 100644 docs/examples/project/update-password-rotation-policy.md create mode 100644 docs/examples/users/delete-passkey.md create mode 100644 docs/examples/users/get-passkey.md rename docs/examples/users/{list-logs.md => list-passkeys.md} (92%) create mode 100644 docs/examples/users/update-passkey.md create mode 100644 docs/examples/waf/create-bypass-rule.md create mode 100644 docs/examples/waf/create-challenge-rule.md create mode 100644 docs/examples/waf/create-deny-rule.md create mode 100644 docs/examples/waf/create-rate-limit-rule.md create mode 100644 docs/examples/waf/create-redirect-rule.md create mode 100644 docs/examples/waf/delete-rule.md create mode 100644 docs/examples/waf/get-rule.md create mode 100644 docs/examples/waf/list-rules.md create mode 100644 docs/examples/waf/update-bypass-rule.md create mode 100644 docs/examples/waf/update-challenge-rule.md create mode 100644 docs/examples/waf/update-deny-rule.md create mode 100644 docs/examples/waf/update-rate-limit-rule.md create mode 100644 docs/examples/waf/update-redirect-rule.md create mode 100644 lib/appwrite/enums/domain_registration_type.rb create mode 100644 lib/appwrite/enums/domain_transfer_status_enum.rb create mode 100644 lib/appwrite/enums/id_token_provider.rb create mode 100644 lib/appwrite/enums/o_auth2_auth0_prompt.rb create mode 100644 lib/appwrite/enums/o_auth2_discord_prompt.rb create mode 100644 lib/appwrite/enums/o_auth2_github_prompt.rb create mode 100644 lib/appwrite/enums/o_auth2_kakao_prompt.rb create mode 100644 lib/appwrite/enums/o_auth2_microsoft_prompt.rb create mode 100644 lib/appwrite/enums/o_auth2_okta_prompt.rb create mode 100644 lib/appwrite/enums/o_auth2_salesforce_prompt.rb create mode 100644 lib/appwrite/enums/o_auth2_zoho_prompt.rb delete mode 100644 lib/appwrite/enums/organization_key_scopes.rb create mode 100644 lib/appwrite/enums/project_o_auth2_auth0_prompt.rb create mode 100644 lib/appwrite/enums/project_o_auth2_discord_prompt.rb create mode 100644 lib/appwrite/enums/project_o_auth2_git_hub_prompt.rb create mode 100644 lib/appwrite/enums/project_o_auth2_kakao_prompt.rb create mode 100644 lib/appwrite/enums/project_o_auth2_microsoft_prompt.rb create mode 100644 lib/appwrite/enums/project_o_auth2_okta_prompt.rb create mode 100644 lib/appwrite/enums/project_o_auth2_salesforce_prompt.rb create mode 100644 lib/appwrite/enums/project_o_auth2_zoho_prompt.rb create mode 100644 lib/appwrite/enums/waf_rule_action.rb create mode 100644 lib/appwrite/models/account.rb delete mode 100644 lib/appwrite/models/dedicated_database_specification_pricing.rb create mode 100644 lib/appwrite/models/dns_record.rb create mode 100644 lib/appwrite/models/dns_records_list.rb create mode 100644 lib/appwrite/models/domain.rb create mode 100644 lib/appwrite/models/domain_price.rb create mode 100644 lib/appwrite/models/domain_prices_list.rb create mode 100644 lib/appwrite/models/domain_transfer_status.rb create mode 100644 lib/appwrite/models/domains_list.rb delete mode 100644 lib/appwrite/models/log.rb create mode 100644 lib/appwrite/models/o_auth2_kakao.rb create mode 100644 lib/appwrite/models/o_auth2_tik_tok.rb create mode 100644 lib/appwrite/models/o_auth2_webflow.rb create mode 100644 lib/appwrite/models/oauth2_introspection.rb rename lib/appwrite/models/{dev_key.rb => passkey.rb} (61%) create mode 100644 lib/appwrite/models/passkey_challenge.rb create mode 100644 lib/appwrite/models/passkey_list.rb create mode 100644 lib/appwrite/models/policy_passkey.rb create mode 100644 lib/appwrite/models/policy_password_pwned.rb create mode 100644 lib/appwrite/models/policy_password_rotation.rb create mode 100644 lib/appwrite/models/token_secret.rb create mode 100644 lib/appwrite/models/waf_rule_bypass.rb create mode 100644 lib/appwrite/models/waf_rule_challenge.rb create mode 100644 lib/appwrite/models/waf_rule_deny.rb rename lib/appwrite/models/{log_list.rb => waf_rule_list.rb} (62%) create mode 100644 lib/appwrite/models/waf_rule_rate_limit.rb create mode 100644 lib/appwrite/models/waf_rule_redirect.rb create mode 100644 lib/appwrite/services/domains.rb create mode 100644 lib/appwrite/services/waf.rb create mode 100644 lib/appwrite/topic.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 5051946b..43af107e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,40 @@ # Change Log +## 29.0.0 + +* Breaking: `account.list_logs`, `users.list_logs`, `Log` and `LogList` removed +* Breaking: `organization` key methods renamed to `create_ephemeral_project_key`, `get_project_key`, `list_project_keys`, `update_project_key` and `delete_project_key`; `OrganizationKeyScopes` removed +* Breaking: `set_dev_key` client method, `DevKey` model and `Project.dev_keys` removed +* Breaking: `project_name`, `region`, `organization_id`, `organization_name`, `billing_plan` and `reason` removed from `Block` +* Breaking: `DedicatedDatabaseSpecificationList.pricing` and `DedicatedDatabaseSpecificationPricing` removed; rates now live on `DedicatedDatabaseSpecification` +* Breaking: `BillingPlanGroup` `starter` replaced by `free` and `start` +* Breaking: `resource` is now an array on `oauth2.authorize`, `oauth2.create_par`, `oauth2.create_token` and `oauth2.create_device_authorization` +* Breaking: `BackupRestoration.options` is now a key-value object instead of a string +* Added: passkey methods `account.list_passkeys`, `account.create_passkey`, `account.get_passkey`, `account.update_passkey`, `account.delete_passkey`, `account.update_passkey_verification`, `account.create_passkey_token` and `account.update_passkey_token` +* Added: `users.list_passkeys`, `users.get_passkey`, `users.update_passkey`, `users.delete_passkey`, plus `project.update_passkey_policy` +* Added: `Passkey`, `PasskeyList`, `PasskeyChallenge`, `PolicyPasskey` and `TokenSecret` models +* Added: `fingerprints` on Android platforms for passkeys +* Added: `domains` service for domains, DNS records, email presets, prices and transfers +* Added: `waf` service for bypass, challenge, deny, rate-limit and redirect rules +* Added: `account.create_id_token_session` for native Apple and Google sign-in, with native client IDs on those providers +* Added: email verification and recovery OTP methods on `account` +* Added: `oauth2.introspect` for RFC 7662 token introspection, returning `Oauth2Introspection` +* Added: `avatars.update_photo` and `avatars.delete_photo` +* Added: `messaging.create_appwrite_provider` and `messaging.update_appwrite_provider` +* Added: `project.update_password_pwned_policy`, `PolicyPasswordPwned` model and `User.password_pwned` +* Added: Kakao, TikTok and Webflow OAuth2 providers +* Added: `prompt` on Auth0, Discord, GitHub, Microsoft, Okta, Salesforce and Zoho providers, with prompt enums +* Added: `Topic` and `ResolvedTopic` helpers for building MQTT push topics +* Added: reply-to on email messages, `channel_id` on push messages, `qos` and `expiry` on topics +* Added: `membership_id` on `teams.create_membership`, and `total` on locale and other list endpoints +* Added: `storage_status` and `storage_target_gb` on `DedicatedDatabase`; `eligible_countries` on `BillingPlan` +* Added: `auto` image gravity, `jaspr` framework, `dart-3.13` and `flutter-3.47` runtimes +* Added: `project.update_password_rotation_policy` and the `PolicyPasswordRotation` model +* Fixed: response models fill missing fields from spec defaults instead of throwing +* Fixed: object parameters in multipart requests are sent as JSON +* Updated: several model fields are now optional and may be `nil`, e.g. `DedicatedDatabase.engine`, `Organization.billing_start_date`, `BillingPlan.usage`, `BackupArchive.size` +* Updated: requests send `X-Appwrite-Response-Format` `2.4.0` + ## 28.2.0 * Added: optional `interval` parameter on `functions.create` and `functions.update` to run a function every N minutes diff --git a/README.md b/README.md index ebd62348..f075f30d 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.4.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.4.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 14229fc6..4054abff 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '28.2.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/create-email-password-session.md b/docs/examples/account/create-email-password-session.md index 57ab742d..2db01b74 100644 --- a/docs/examples/account/create-email-password-session.md +++ b/docs/examples/account/create-email-password-session.md @@ -12,6 +12,7 @@ account = Account.new(client) result = account.create_email_password_session( email: 'email@example.com', - password: 'password' + password: 'password', + duration: 60 # optional ) ``` diff --git a/docs/examples/account/create-email-verification-otp.md b/docs/examples/account/create-email-verification-otp.md new file mode 100644 index 00000000..618575b3 --- /dev/null +++ b/docs/examples/account/create-email-verification-otp.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.create_email_verification_otp( + phrase: false # optional +) +``` diff --git a/docs/examples/account/create-id-token-session.md b/docs/examples/account/create-id-token-session.md new file mode 100644 index 00000000..3a244017 --- /dev/null +++ b/docs/examples/account/create-id-token-session.md @@ -0,0 +1,22 @@ +```ruby +require 'appwrite' + +include Appwrite +include Appwrite::Enums + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.create_id_token_session( + provider: IdTokenProvider::APPLE, + id_token: '', + nonce: '', # optional + access_token: '', # optional + access_token_expiry: 0, # optional + name: '' # optional +) +``` diff --git a/docs/examples/account/create-passkey-token.md b/docs/examples/account/create-passkey-token.md new file mode 100644 index 00000000..c3f48ed2 --- /dev/null +++ b/docs/examples/account/create-passkey-token.md @@ -0,0 +1,14 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.create_passkey_token() +``` diff --git a/docs/examples/account/create-passkey.md b/docs/examples/account/create-passkey.md new file mode 100644 index 00000000..c699aa22 --- /dev/null +++ b/docs/examples/account/create-passkey.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.create_passkey( + passkey_id: '', # optional + name: '' # optional +) +``` diff --git a/docs/examples/account/create-recovery-otp.md b/docs/examples/account/create-recovery-otp.md new file mode 100644 index 00000000..06aff8ec --- /dev/null +++ b/docs/examples/account/create-recovery-otp.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.create_recovery_otp( + email: 'email@example.com', + phrase: false # optional +) +``` diff --git a/docs/examples/account/delete-passkey.md b/docs/examples/account/delete-passkey.md new file mode 100644 index 00000000..740ba97a --- /dev/null +++ b/docs/examples/account/delete-passkey.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.delete_passkey( + passkey_id: '' +) +``` diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md index 3008032f..b7143c0c 100644 --- a/docs/examples/account/delete-sessions.md +++ b/docs/examples/account/delete-sessions.md @@ -10,5 +10,7 @@ client = Client.new account = Account.new(client) -result = account.delete_sessions() +result = account.delete_sessions( + current: false # optional +) ``` diff --git a/docs/examples/account/get-passkey.md b/docs/examples/account/get-passkey.md new file mode 100644 index 00000000..705e41a1 --- /dev/null +++ b/docs/examples/account/get-passkey.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.get_passkey( + passkey_id: '' +) +``` diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-passkeys.md similarity index 91% rename from docs/examples/account/list-logs.md rename to docs/examples/account/list-passkeys.md index 171d4306..8c58601f 100644 --- a/docs/examples/account/list-logs.md +++ b/docs/examples/account/list-passkeys.md @@ -10,7 +10,7 @@ client = Client.new account = Account.new(client) -result = account.list_logs( +result = account.list_passkeys( queries: [], # optional total: false # optional ) diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md index 47d2c033..5b810eb9 100644 --- a/docs/examples/account/list-sessions.md +++ b/docs/examples/account/list-sessions.md @@ -10,5 +10,7 @@ client = Client.new account = Account.new(client) -result = account.list_sessions() +result = account.list_sessions( + total: false # optional +) ``` diff --git a/docs/examples/account/update-email-verification-otp.md b/docs/examples/account/update-email-verification-otp.md new file mode 100644 index 00000000..dd20ac13 --- /dev/null +++ b/docs/examples/account/update-email-verification-otp.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.update_email_verification_otp( + user_id: '', + secret: '' +) +``` diff --git a/docs/examples/account/update-passkey-token.md b/docs/examples/account/update-passkey-token.md new file mode 100644 index 00000000..406e91e3 --- /dev/null +++ b/docs/examples/account/update-passkey-token.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.update_passkey_token( + challenge_id: '', + credential: {} +) +``` diff --git a/docs/examples/account/update-passkey-verification.md b/docs/examples/account/update-passkey-verification.md new file mode 100644 index 00000000..fb2671d3 --- /dev/null +++ b/docs/examples/account/update-passkey-verification.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.update_passkey_verification( + passkey_id: '', + credential: {} +) +``` diff --git a/docs/examples/account/update-passkey.md b/docs/examples/account/update-passkey.md new file mode 100644 index 00000000..07f3ff35 --- /dev/null +++ b/docs/examples/account/update-passkey.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.update_passkey( + passkey_id: '', + name: '' +) +``` diff --git a/docs/examples/account/update-recovery-otp.md b/docs/examples/account/update-recovery-otp.md new file mode 100644 index 00000000..4376249c --- /dev/null +++ b/docs/examples/account/update-recovery-otp.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +account = Account.new(client) + +result = account.update_recovery_otp( + user_id: '', + secret: '', + password: 'password' +) +``` diff --git a/docs/examples/avatars/delete-photo.md b/docs/examples/avatars/delete-photo.md new file mode 100644 index 00000000..87dadb8b --- /dev/null +++ b/docs/examples/avatars/delete-photo.md @@ -0,0 +1,14 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +avatars = Avatars.new(client) + +result = avatars.delete_photo() +``` diff --git a/docs/examples/avatars/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/avatars/update-photo.md b/docs/examples/avatars/update-photo.md new file mode 100644 index 00000000..221de406 --- /dev/null +++ b/docs/examples/avatars/update-photo.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_session('') # The user session to authenticate with + +avatars = Avatars.new(client) + +result = avatars.update_photo( + file: InputFile.from_path('dir/file.png') +) +``` diff --git a/docs/examples/databases/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/list-transactions.md b/docs/examples/databases/list-transactions.md index 9071982e..12daa7a1 100644 --- a/docs/examples/databases/list-transactions.md +++ b/docs/examples/databases/list-transactions.md @@ -11,6 +11,7 @@ client = Client.new databases = Databases.new(client) result = databases.list_transactions( - queries: [] # optional + queries: [], # optional + total: false # optional ) ``` diff --git a/docs/examples/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/list-transactions.md b/docs/examples/documentsdb/list-transactions.md index 82d368e1..2128e4f8 100644 --- a/docs/examples/documentsdb/list-transactions.md +++ b/docs/examples/documentsdb/list-transactions.md @@ -11,6 +11,7 @@ client = Client.new documents_db = DocumentsDB.new(client) result = documents_db.list_transactions( - queries: [] # optional + queries: [], # optional + total: false # optional ) ``` diff --git a/docs/examples/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/create-preset-google-workspace.md b/docs/examples/domains/create-preset-google-workspace.md new file mode 100644 index 00000000..d81c279f --- /dev/null +++ b/docs/examples/domains/create-preset-google-workspace.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_preset_google_workspace( + domain_id: '' +) +``` diff --git a/docs/examples/domains/create-preset-i-cloud.md b/docs/examples/domains/create-preset-i-cloud.md new file mode 100644 index 00000000..531f3c5d --- /dev/null +++ b/docs/examples/domains/create-preset-i-cloud.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_preset_i_cloud( + domain_id: '' +) +``` diff --git a/docs/examples/domains/create-preset-mailgun.md b/docs/examples/domains/create-preset-mailgun.md new file mode 100644 index 00000000..2b39a5c3 --- /dev/null +++ b/docs/examples/domains/create-preset-mailgun.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_preset_mailgun( + domain_id: '' +) +``` diff --git a/docs/examples/domains/create-preset-outlook.md b/docs/examples/domains/create-preset-outlook.md new file mode 100644 index 00000000..e67b5857 --- /dev/null +++ b/docs/examples/domains/create-preset-outlook.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_preset_outlook( + domain_id: '' +) +``` diff --git a/docs/examples/domains/create-preset-proton-mail.md b/docs/examples/domains/create-preset-proton-mail.md new file mode 100644 index 00000000..ecbbecd6 --- /dev/null +++ b/docs/examples/domains/create-preset-proton-mail.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_preset_proton_mail( + domain_id: '' +) +``` diff --git a/docs/examples/domains/create-preset-zoho.md b/docs/examples/domains/create-preset-zoho.md new file mode 100644 index 00000000..d79be6e8 --- /dev/null +++ b/docs/examples/domains/create-preset-zoho.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_preset_zoho( + domain_id: '' +) +``` diff --git a/docs/examples/domains/create-record-a.md b/docs/examples/domains/create-record-a.md new file mode 100644 index 00000000..0d164ab4 --- /dev/null +++ b/docs/examples/domains/create-record-a.md @@ -0,0 +1,20 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_record_a( + domain_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-aaaa.md b/docs/examples/domains/create-record-aaaa.md new file mode 100644 index 00000000..8dc59646 --- /dev/null +++ b/docs/examples/domains/create-record-aaaa.md @@ -0,0 +1,20 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_record_aaaa( + domain_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-alias.md b/docs/examples/domains/create-record-alias.md new file mode 100644 index 00000000..fbb10b8f --- /dev/null +++ b/docs/examples/domains/create-record-alias.md @@ -0,0 +1,20 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_record_alias( + domain_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-caa.md b/docs/examples/domains/create-record-caa.md new file mode 100644 index 00000000..5ec76857 --- /dev/null +++ b/docs/examples/domains/create-record-caa.md @@ -0,0 +1,20 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_record_caa( + domain_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-cname.md b/docs/examples/domains/create-record-cname.md new file mode 100644 index 00000000..d5d81fb8 --- /dev/null +++ b/docs/examples/domains/create-record-cname.md @@ -0,0 +1,20 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_record_cname( + domain_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-https.md b/docs/examples/domains/create-record-https.md new file mode 100644 index 00000000..54276b77 --- /dev/null +++ b/docs/examples/domains/create-record-https.md @@ -0,0 +1,20 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_record_https( + domain_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-mx.md b/docs/examples/domains/create-record-mx.md new file mode 100644 index 00000000..41bc9c7d --- /dev/null +++ b/docs/examples/domains/create-record-mx.md @@ -0,0 +1,21 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_record_mx( + domain_id: '', + name: '', + value: '', + ttl: 1, + priority: 0, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-ns.md b/docs/examples/domains/create-record-ns.md new file mode 100644 index 00000000..155d9040 --- /dev/null +++ b/docs/examples/domains/create-record-ns.md @@ -0,0 +1,20 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_record_ns( + domain_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-srv.md b/docs/examples/domains/create-record-srv.md new file mode 100644 index 00000000..40f97aac --- /dev/null +++ b/docs/examples/domains/create-record-srv.md @@ -0,0 +1,23 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_record_srv( + domain_id: '', + name: '', + value: '', + ttl: 1, + priority: 0, + weight: 0, + port: 0, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create-record-txt.md b/docs/examples/domains/create-record-txt.md new file mode 100644 index 00000000..01d9e6db --- /dev/null +++ b/docs/examples/domains/create-record-txt.md @@ -0,0 +1,20 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create_record_txt( + domain_id: '', + name: '', + ttl: 1, + value: '', # optional + comment: '' # optional +) +``` diff --git a/docs/examples/domains/create.md b/docs/examples/domains/create.md new file mode 100644 index 00000000..765a5fba --- /dev/null +++ b/docs/examples/domains/create.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.create( + team_id: '', + domain: 'example.com' +) +``` diff --git a/docs/examples/domains/delete-record.md b/docs/examples/domains/delete-record.md new file mode 100644 index 00000000..8aafe5d5 --- /dev/null +++ b/docs/examples/domains/delete-record.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.delete_record( + domain_id: '', + record_id: '' +) +``` diff --git a/docs/examples/domains/delete.md b/docs/examples/domains/delete.md new file mode 100644 index 00000000..42520ee5 --- /dev/null +++ b/docs/examples/domains/delete.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.delete( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-preset-google-workspace.md b/docs/examples/domains/get-preset-google-workspace.md new file mode 100644 index 00000000..42db938a --- /dev/null +++ b/docs/examples/domains/get-preset-google-workspace.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.get_preset_google_workspace( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-preset-i-cloud.md b/docs/examples/domains/get-preset-i-cloud.md new file mode 100644 index 00000000..35713afa --- /dev/null +++ b/docs/examples/domains/get-preset-i-cloud.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.get_preset_i_cloud( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-preset-mailgun.md b/docs/examples/domains/get-preset-mailgun.md new file mode 100644 index 00000000..82ad69fc --- /dev/null +++ b/docs/examples/domains/get-preset-mailgun.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.get_preset_mailgun( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-preset-outlook.md b/docs/examples/domains/get-preset-outlook.md new file mode 100644 index 00000000..887b514b --- /dev/null +++ b/docs/examples/domains/get-preset-outlook.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.get_preset_outlook( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-preset-proton-mail.md b/docs/examples/domains/get-preset-proton-mail.md new file mode 100644 index 00000000..01661d2d --- /dev/null +++ b/docs/examples/domains/get-preset-proton-mail.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.get_preset_proton_mail( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-preset-zoho.md b/docs/examples/domains/get-preset-zoho.md new file mode 100644 index 00000000..e5339dc1 --- /dev/null +++ b/docs/examples/domains/get-preset-zoho.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.get_preset_zoho( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-price.md b/docs/examples/domains/get-price.md new file mode 100644 index 00000000..7727397c --- /dev/null +++ b/docs/examples/domains/get-price.md @@ -0,0 +1,19 @@ +```ruby +require 'appwrite' + +include Appwrite +include Appwrite::Enums + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.get_price( + domain: 'example.com', + period_years: null, # optional + registration_type: DomainRegistrationType::NEW # optional +) +``` diff --git a/docs/examples/domains/get-record.md b/docs/examples/domains/get-record.md new file mode 100644 index 00000000..2f55038a --- /dev/null +++ b/docs/examples/domains/get-record.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.get_record( + domain_id: '', + record_id: '' +) +``` diff --git a/docs/examples/domains/get-transfer-status.md b/docs/examples/domains/get-transfer-status.md new file mode 100644 index 00000000..e3b8b537 --- /dev/null +++ b/docs/examples/domains/get-transfer-status.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.get_transfer_status( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get-zone.md b/docs/examples/domains/get-zone.md new file mode 100644 index 00000000..b3693663 --- /dev/null +++ b/docs/examples/domains/get-zone.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.get_zone( + domain_id: '' +) +``` diff --git a/docs/examples/domains/get.md b/docs/examples/domains/get.md new file mode 100644 index 00000000..bca8160e --- /dev/null +++ b/docs/examples/domains/get.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.get( + domain_id: '' +) +``` diff --git a/docs/examples/domains/list-prices.md b/docs/examples/domains/list-prices.md new file mode 100644 index 00000000..14ced00c --- /dev/null +++ b/docs/examples/domains/list-prices.md @@ -0,0 +1,19 @@ +```ruby +require 'appwrite' + +include Appwrite +include Appwrite::Enums + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.list_prices( + domains: [], + period_years: null, # optional + registration_type: DomainRegistrationType::NEW # optional +) +``` diff --git a/docs/examples/domains/list-records.md b/docs/examples/domains/list-records.md new file mode 100644 index 00000000..d25f19ad --- /dev/null +++ b/docs/examples/domains/list-records.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.list_records( + domain_id: '', + queries: [] # optional +) +``` diff --git a/docs/examples/domains/list.md b/docs/examples/domains/list.md new file mode 100644 index 00000000..44fcf339 --- /dev/null +++ b/docs/examples/domains/list.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.list( + queries: [], # optional + search: '' # optional +) +``` diff --git a/docs/examples/domains/update-nameservers.md b/docs/examples/domains/update-nameservers.md new file mode 100644 index 00000000..d6166825 --- /dev/null +++ b/docs/examples/domains/update-nameservers.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.update_nameservers( + domain_id: '', + nameservers: [] # optional +) +``` diff --git a/docs/examples/domains/update-record-a.md b/docs/examples/domains/update-record-a.md new file mode 100644 index 00000000..927597d1 --- /dev/null +++ b/docs/examples/domains/update-record-a.md @@ -0,0 +1,21 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.update_record_a( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-aaaa.md b/docs/examples/domains/update-record-aaaa.md new file mode 100644 index 00000000..6d20866b --- /dev/null +++ b/docs/examples/domains/update-record-aaaa.md @@ -0,0 +1,21 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.update_record_aaaa( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-alias.md b/docs/examples/domains/update-record-alias.md new file mode 100644 index 00000000..17558e8e --- /dev/null +++ b/docs/examples/domains/update-record-alias.md @@ -0,0 +1,21 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.update_record_alias( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-caa.md b/docs/examples/domains/update-record-caa.md new file mode 100644 index 00000000..d77eec0f --- /dev/null +++ b/docs/examples/domains/update-record-caa.md @@ -0,0 +1,21 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.update_record_caa( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-cname.md b/docs/examples/domains/update-record-cname.md new file mode 100644 index 00000000..3ec0aa0f --- /dev/null +++ b/docs/examples/domains/update-record-cname.md @@ -0,0 +1,21 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.update_record_cname( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-https.md b/docs/examples/domains/update-record-https.md new file mode 100644 index 00000000..848a7c31 --- /dev/null +++ b/docs/examples/domains/update-record-https.md @@ -0,0 +1,21 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.update_record_https( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-mx.md b/docs/examples/domains/update-record-mx.md new file mode 100644 index 00000000..4cf0cf8d --- /dev/null +++ b/docs/examples/domains/update-record-mx.md @@ -0,0 +1,22 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.update_record_mx( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + priority: 0, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-ns.md b/docs/examples/domains/update-record-ns.md new file mode 100644 index 00000000..30974d70 --- /dev/null +++ b/docs/examples/domains/update-record-ns.md @@ -0,0 +1,21 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.update_record_ns( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-srv.md b/docs/examples/domains/update-record-srv.md new file mode 100644 index 00000000..9b02cd69 --- /dev/null +++ b/docs/examples/domains/update-record-srv.md @@ -0,0 +1,24 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.update_record_srv( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + priority: 0, + weight: 0, + port: 0, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-record-txt.md b/docs/examples/domains/update-record-txt.md new file mode 100644 index 00000000..89a777ed --- /dev/null +++ b/docs/examples/domains/update-record-txt.md @@ -0,0 +1,21 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.update_record_txt( + domain_id: '', + record_id: '', + name: '', + value: '', + ttl: 1, + comment: '' # optional +) +``` diff --git a/docs/examples/domains/update-team.md b/docs/examples/domains/update-team.md new file mode 100644 index 00000000..03e4a81d --- /dev/null +++ b/docs/examples/domains/update-team.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.update_team( + domain_id: '', + team_id: '' +) +``` diff --git a/docs/examples/domains/update-zone.md b/docs/examples/domains/update-zone.md new file mode 100644 index 00000000..f7c145ee --- /dev/null +++ b/docs/examples/domains/update-zone.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.update_zone( + domain_id: '', + content: '' +) +``` diff --git a/docs/examples/domains/verify-nameservers.md b/docs/examples/domains/verify-nameservers.md new file mode 100644 index 00000000..cfbf8e3c --- /dev/null +++ b/docs/examples/domains/verify-nameservers.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +domains = Domains.new(client) + +result = domains.verify_nameservers( + domain_id: '' +) +``` diff --git a/docs/examples/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/list-runtimes.md b/docs/examples/functions/list-runtimes.md index 98a75466..99eecff4 100644 --- a/docs/examples/functions/list-runtimes.md +++ b/docs/examples/functions/list-runtimes.md @@ -10,5 +10,7 @@ client = Client.new functions = Functions.new(client) -result = functions.list_runtimes() +result = functions.list_runtimes( + total: false # optional +) ``` diff --git a/docs/examples/functions/list-specifications.md b/docs/examples/functions/list-specifications.md index 635f73a5..34f12bb0 100644 --- a/docs/examples/functions/list-specifications.md +++ b/docs/examples/functions/list-specifications.md @@ -11,6 +11,7 @@ client = Client.new functions = Functions.new(client) result = functions.list_specifications( - type: 'runtimes' # optional + type: 'runtimes', # optional + total: false # optional ) ``` diff --git a/docs/examples/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/locale/list-codes.md b/docs/examples/locale/list-codes.md index cf31d3af..6935229a 100644 --- a/docs/examples/locale/list-codes.md +++ b/docs/examples/locale/list-codes.md @@ -10,5 +10,7 @@ client = Client.new locale = Locale.new(client) -result = locale.list_codes() +result = locale.list_codes( + total: false # optional +) ``` diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md index 1470c7d1..2e97e0b3 100644 --- a/docs/examples/locale/list-continents.md +++ b/docs/examples/locale/list-continents.md @@ -10,5 +10,7 @@ client = Client.new locale = Locale.new(client) -result = locale.list_continents() +result = locale.list_continents( + total: false # optional +) ``` diff --git a/docs/examples/locale/list-countries-eu.md b/docs/examples/locale/list-countries-eu.md index 7ca1e985..b54270b7 100644 --- a/docs/examples/locale/list-countries-eu.md +++ b/docs/examples/locale/list-countries-eu.md @@ -10,5 +10,7 @@ client = Client.new locale = Locale.new(client) -result = locale.list_countries_eu() +result = locale.list_countries_eu( + total: false # optional +) ``` diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md index 43c80c6a..de45f6b6 100644 --- a/docs/examples/locale/list-countries-phones.md +++ b/docs/examples/locale/list-countries-phones.md @@ -10,5 +10,7 @@ client = Client.new locale = Locale.new(client) -result = locale.list_countries_phones() +result = locale.list_countries_phones( + total: false # optional +) ``` diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md index a5a81c7b..a985d20b 100644 --- a/docs/examples/locale/list-countries.md +++ b/docs/examples/locale/list-countries.md @@ -10,5 +10,7 @@ client = Client.new locale = Locale.new(client) -result = locale.list_countries() +result = locale.list_countries( + total: false # optional +) ``` diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md index a5316f2b..2b698f1e 100644 --- a/docs/examples/locale/list-currencies.md +++ b/docs/examples/locale/list-currencies.md @@ -10,5 +10,7 @@ client = Client.new locale = Locale.new(client) -result = locale.list_currencies() +result = locale.list_currencies( + total: false # optional +) ``` diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md index 9c8655f4..8c0f1ae1 100644 --- a/docs/examples/locale/list-languages.md +++ b/docs/examples/locale/list-languages.md @@ -10,5 +10,7 @@ client = Client.new locale = Locale.new(client) -result = locale.list_languages() +result = locale.list_languages( + total: false # optional +) ``` diff --git a/docs/examples/messaging/create-appwrite-provider.md b/docs/examples/messaging/create-appwrite-provider.md new file mode 100644 index 00000000..ae56ec57 --- /dev/null +++ b/docs/examples/messaging/create-appwrite-provider.md @@ -0,0 +1,20 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +messaging = Messaging.new(client) + +result = messaging.create_appwrite_provider( + provider_id: '', + name: '', + enabled: false, # optional + qos: 0, # optional + expiry: 0 # optional +) +``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index e661a8a3..694e5032 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -20,6 +20,8 @@ result = messaging.create_email( cc: [], # optional bcc: [], # optional attachments: [], # optional + reply_to_email: 'email@example.com', # optional + reply_to_name: '', # optional draft: false, # optional html: false, # optional scheduled_at: '2020-10-15T06:38:00.000+00:00' # optional diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index e94015e6..c1488a49 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -30,6 +30,7 @@ result = messaging.create_push( scheduled_at: '2020-10-15T06:38:00.000+00:00', # optional content_available: false, # optional critical: false, # optional - priority: MessagePriority::NORMAL # optional + priority: MessagePriority::NORMAL, # optional + channel_id: '' # optional ) ``` diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md index 85cc5d76..2b650e9f 100644 --- a/docs/examples/messaging/create-topic.md +++ b/docs/examples/messaging/create-topic.md @@ -13,6 +13,8 @@ messaging = Messaging.new(client) result = messaging.create_topic( topic_id: '', name: '', - subscribe: ["any"] # optional + subscribe: ["any"], # optional + qos: 0, # optional + expiry: 0 # optional ) ``` diff --git a/docs/examples/messaging/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/messaging/update-appwrite-provider.md b/docs/examples/messaging/update-appwrite-provider.md new file mode 100644 index 00000000..e35af727 --- /dev/null +++ b/docs/examples/messaging/update-appwrite-provider.md @@ -0,0 +1,20 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +messaging = Messaging.new(client) + +result = messaging.update_appwrite_provider( + provider_id: '', + name: '', # optional + enabled: false, # optional + qos: 0, # optional + expiry: 0 # optional +) +``` diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index 727fdbc2..0d918ba4 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -12,16 +12,18 @@ messaging = Messaging.new(client) result = messaging.update_email( message_id: '', + subject: '', # optional + content: '', # optional topics: [], # optional users: [], # optional targets: [], # optional - subject: '', # optional - content: '', # optional - draft: false, # optional - html: false, # optional cc: [], # optional bcc: [], # optional - scheduled_at: '2020-10-15T06:38:00.000+00:00', # optional - attachments: [] # optional + attachments: [], # optional + reply_to_email: 'email@example.com', # optional + reply_to_name: '', # optional + draft: false, # optional + html: false, # optional + scheduled_at: '2020-10-15T06:38:00.000+00:00' # optional ) ``` diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index 9aa0e8ba..41323dbc 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -13,11 +13,11 @@ messaging = Messaging.new(client) result = messaging.update_push( message_id: '', + title: '', # optional + body: '<BODY>', # optional topics: [], # optional users: [], # optional targets: [], # optional - title: '<TITLE>', # optional - body: '<BODY>', # optional data: {}, # optional action: '<ACTION>', # optional image: '<ID1:ID2>', # optional @@ -30,6 +30,7 @@ result = messaging.update_push( scheduled_at: '2020-10-15T06:38:00.000+00:00', # optional content_available: false, # optional critical: false, # optional - priority: MessagePriority::NORMAL # optional + priority: MessagePriority::NORMAL, # optional + channel_id: '<CHANNEL_ID>' # optional ) ``` diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 233ffb81..41e9827e 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -12,10 +12,10 @@ messaging = Messaging.new(client) result = messaging.update_sms( message_id: '<MESSAGE_ID>', + content: '<CONTENT>', # optional topics: [], # optional users: [], # optional targets: [], # optional - content: '<CONTENT>', # optional draft: false, # optional scheduled_at: '2020-10-15T06:38:00.000+00:00' # optional ) diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md index af1ed82f..43d8ce01 100644 --- a/docs/examples/messaging/update-topic.md +++ b/docs/examples/messaging/update-topic.md @@ -13,6 +13,8 @@ messaging = Messaging.new(client) result = messaging.update_topic( topic_id: '<TOPIC_ID>', name: '<NAME>', # optional - subscribe: ["any"] # optional + subscribe: ["any"], # optional + qos: 0, # optional + expiry: 0 # 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://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint - .set_session('') # The user session to authenticate with .set_project('<YOUR_PROJECT_ID>') # 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://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint - .set_session('') # The user session to authenticate with .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -22,7 +22,7 @@ result = oauth2.authorize_post( prompt: '<PROMPT>', # optional max_age: 0, # optional authorization_details: '<AUTHORIZATION_DETAILS>', # optional - resource: '', # optional + resource: [], # optional audience: '<AUDIENCE>', # optional request_uri: '<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://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint - .set_session('') # The user session to authenticate with .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -22,7 +22,7 @@ result = oauth2.authorize( prompt: '<PROMPT>', # optional max_age: 0, # optional authorization_details: '<AUTHORIZATION_DETAILS>', # optional - resource: '', # optional + resource: [], # optional audience: '<AUDIENCE>', # optional request_uri: '<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://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint - .set_session('') # The user session to authenticate with .set_project('<YOUR_PROJECT_ID>') # 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: '<CLIENT_ID>', # optional scope: '<SCOPE>', # optional authorization_details: '<AUTHORIZATION_DETAILS>', # optional - resource: '', # optional + resource: [], # optional audience: '<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://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint - .set_session('') # The user session to authenticate with .set_project('<YOUR_PROJECT_ID>') # 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://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint - .set_session('') # The user session to authenticate with .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) @@ -22,7 +22,7 @@ result = oauth2.create_par( prompt: '<PROMPT>', # optional max_age: 0, # optional authorization_details: '<AUTHORIZATION_DETAILS>', # optional - resource: '', # optional + resource: [], # optional audience: '<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://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint - .set_session('') # The user session to authenticate with .set_project('<YOUR_PROJECT_ID>') # 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: '<CLIENT_SECRET>', # optional code_verifier: '<CODE_VERIFIER>', # optional redirect_uri: 'https://example.com', # optional - resource: '', # optional + resource: [], # optional audience: '<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://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint - .set_session('') # The user session to authenticate with .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_session('') # The user session to authenticate with oauth2 = Oauth2.new(client) diff --git a/docs/examples/oauth2/introspect.md b/docs/examples/oauth2/introspect.md new file mode 100644 index 00000000..1ff23370 --- /dev/null +++ b/docs/examples/oauth2/introspect.md @@ -0,0 +1,19 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +oauth2 = Oauth2.new(client) + +result = oauth2.introspect( + token: '<TOKEN>', + token_type_hint: 'access_token', # optional + client_id: '<CLIENT_ID>', # optional + client_secret: '<CLIENT_SECRET>' # optional +) +``` 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://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint - .set_session('') # The user session to authenticate with .set_project('<YOUR_PROJECT_ID>') # 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://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint - .set_session('') # The user session to authenticate with .set_project('<YOUR_PROJECT_ID>') # 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://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint - .set_session('') # The user session to authenticate with .set_project('<YOUR_PROJECT_ID>') # 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://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint - .set_session('') # The user session to authenticate with .set_project('<YOUR_PROJECT_ID>') # 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-ephemeral-project-key.md similarity index 63% rename from docs/examples/organization/create-key.md rename to docs/examples/organization/create-ephemeral-project-key.md index 3d920ccc..62814ac1 100644 --- a/docs/examples/organization/create-key.md +++ b/docs/examples/organization/create-ephemeral-project-key.md @@ -11,10 +11,9 @@ client = Client.new organization = Organization.new(client) -result = organization.create_key( - key_id: '<KEY_ID>', - name: '<NAME>', - scopes: [OrganizationKeyScopes::PROJECTS_READ], - expire: '2020-10-15T06:38:00.000+00:00' # optional +result = organization.create_ephemeral_project_key( + project_id: '<PROJECT_ID>', + scopes: [ProjectKeyScopes::USERS_READ], + duration: 600 ) ``` diff --git a/docs/examples/organization/get-key.md b/docs/examples/organization/delete-project-key.md similarity index 81% rename from docs/examples/organization/get-key.md rename to docs/examples/organization/delete-project-key.md index 28899bb6..f96b65e4 100644 --- a/docs/examples/organization/get-key.md +++ b/docs/examples/organization/delete-project-key.md @@ -10,7 +10,8 @@ client = Client.new organization = Organization.new(client) -result = organization.get_key( +result = organization.delete_project_key( + project_id: '<PROJECT_ID>', key_id: '<KEY_ID>' ) ``` diff --git a/docs/examples/organization/delete-key.md b/docs/examples/organization/get-project-key.md similarity index 82% rename from docs/examples/organization/delete-key.md rename to docs/examples/organization/get-project-key.md index 0e490c3b..8270214d 100644 --- a/docs/examples/organization/delete-key.md +++ b/docs/examples/organization/get-project-key.md @@ -10,7 +10,8 @@ client = Client.new organization = Organization.new(client) -result = organization.delete_key( +result = organization.get_project_key( + project_id: '<PROJECT_ID>', key_id: '<KEY_ID>' ) ``` diff --git a/docs/examples/organization/list-keys.md b/docs/examples/organization/list-project-keys.md similarity index 83% rename from docs/examples/organization/list-keys.md rename to docs/examples/organization/list-project-keys.md index d54a2642..a2697641 100644 --- a/docs/examples/organization/list-keys.md +++ b/docs/examples/organization/list-project-keys.md @@ -10,7 +10,8 @@ client = Client.new organization = Organization.new(client) -result = organization.list_keys( +result = organization.list_project_keys( + project_id: '<PROJECT_ID>', queries: [], # optional total: false # optional ) diff --git a/docs/examples/organization/update-key.md b/docs/examples/organization/update-project-key.md similarity index 78% rename from docs/examples/organization/update-key.md rename to docs/examples/organization/update-project-key.md index c7542126..2908cae5 100644 --- a/docs/examples/organization/update-key.md +++ b/docs/examples/organization/update-project-key.md @@ -11,10 +11,11 @@ client = Client.new organization = Organization.new(client) -result = organization.update_key( +result = organization.update_project_key( + project_id: '<PROJECT_ID>', key_id: '<KEY_ID>', name: '<NAME>', - scopes: [OrganizationKeyScopes::PROJECTS_READ], + scopes: [ProjectKeyScopes::USERS_READ], expire: '2020-10-15T06:38:00.000+00:00' # optional ) ``` diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md index 31c9725e..0caa3ca9 100644 --- a/docs/examples/project/create-android-platform.md +++ b/docs/examples/project/create-android-platform.md @@ -13,6 +13,7 @@ project = Project.new(client) result = project.create_android_platform( platform_id: '<PLATFORM_ID>', name: '<NAME>', - application_id: '<APPLICATION_ID>' + application_id: '<APPLICATION_ID>', + fingerprints: [] # 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-android-platform.md b/docs/examples/project/update-android-platform.md index 07e177d2..827a321a 100644 --- a/docs/examples/project/update-android-platform.md +++ b/docs/examples/project/update-android-platform.md @@ -13,6 +13,7 @@ project = Project.new(client) result = project.update_android_platform( platform_id: '<PLATFORM_ID>', name: '<NAME>', - application_id: '<APPLICATION_ID>' + application_id: '<APPLICATION_ID>', + fingerprints: [] # optional ) ``` 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: '<KEY_ID>', name: '<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-apple.md b/docs/examples/project/update-o-auth-2-apple.md index adb2c8d6..a8c259e3 100644 --- a/docs/examples/project/update-o-auth-2-apple.md +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -15,6 +15,8 @@ result = project.update_o_auth2_apple( key_id: '<KEY_ID>', # optional team_id: '<TEAM_ID>', # optional p8_file: '<P8_FILE>', # optional - enabled: false # optional + native_client_ids: [], # optional + enabled: false, # optional + native_enabled: false # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md index e8d11dbf..6af0dc83 100644 --- a/docs/examples/project/update-o-auth-2-auth-0.md +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -2,6 +2,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -14,6 +15,7 @@ result = project.update_o_auth2_auth0( client_id: '<CLIENT_ID>', # optional client_secret: '<CLIENT_SECRET>', # optional endpoint: '<ENDPOINT>', # optional + prompt: [ProjectOAuth2Auth0Prompt::NONE], # optional enabled: false # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md index 01bacd7c..1e8409f5 100644 --- a/docs/examples/project/update-o-auth-2-discord.md +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -2,6 +2,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -13,6 +14,7 @@ project = Project.new(client) result = project.update_o_auth2_discord( client_id: '<CLIENT_ID>', # optional client_secret: '<CLIENT_SECRET>', # optional + prompt: [ProjectOAuth2DiscordPrompt::NONE], # optional enabled: false # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md index e63370f7..d209a7b9 100644 --- a/docs/examples/project/update-o-auth-2-git-hub.md +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -2,6 +2,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -13,6 +14,7 @@ project = Project.new(client) result = project.update_o_auth2_git_hub( client_id: '<CLIENT_ID>', # optional client_secret: '<CLIENT_SECRET>', # optional + prompt: [ProjectOAuth2GitHubPrompt::SELECT_ACCOUNT], # optional enabled: false # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md index be38c0f3..7c21efe6 100644 --- a/docs/examples/project/update-o-auth-2-google.md +++ b/docs/examples/project/update-o-auth-2-google.md @@ -15,6 +15,8 @@ result = project.update_o_auth2_google( client_id: '<CLIENT_ID>', # optional client_secret: '<CLIENT_SECRET>', # optional prompt: [ProjectOAuth2GooglePrompt::NONE], # optional - enabled: false # optional + native_client_ids: [], # optional + enabled: false, # optional + native_enabled: false # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md new file mode 100644 index 00000000..035810f7 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -0,0 +1,20 @@ +```ruby +require 'appwrite' + +include Appwrite +include Appwrite::Enums + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +project = Project.new(client) + +result = project.update_o_auth2_kakao( + client_id: '<CLIENT_ID>', # optional + client_secret: '<CLIENT_SECRET>', # optional + prompt: [ProjectOAuth2KakaoPrompt::NONE], # optional + enabled: false # optional +) +``` diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md index 0a5563f7..b5aead55 100644 --- a/docs/examples/project/update-o-auth-2-microsoft.md +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -2,6 +2,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -14,6 +15,7 @@ result = project.update_o_auth2_microsoft( application_id: '<APPLICATION_ID>', # optional application_secret: '<APPLICATION_SECRET>', # optional tenant: '<TENANT>', # optional + prompt: [ProjectOAuth2MicrosoftPrompt::NONE], # optional enabled: false # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md index 44716551..87b6da35 100644 --- a/docs/examples/project/update-o-auth-2-okta.md +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -2,6 +2,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -15,6 +16,7 @@ result = project.update_o_auth2_okta( client_secret: '<CLIENT_SECRET>', # optional domain: 'example.com', # optional authorization_server_id: '<AUTHORIZATION_SERVER_ID>', # optional + prompt: [ProjectOAuth2OktaPrompt::NONE], # optional enabled: false # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md index f573693f..b569cfa4 100644 --- a/docs/examples/project/update-o-auth-2-salesforce.md +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -2,6 +2,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -13,6 +14,7 @@ project = Project.new(client) result = project.update_o_auth2_salesforce( customer_key: '<CUSTOMER_KEY>', # optional customer_secret: '<CUSTOMER_SECRET>', # optional + prompt: [ProjectOAuth2SalesforcePrompt::LOGIN], # optional enabled: false # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-tik-tok.md b/docs/examples/project/update-o-auth-2-tik-tok.md new file mode 100644 index 00000000..36b8ceea --- /dev/null +++ b/docs/examples/project/update-o-auth-2-tik-tok.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +project = Project.new(client) + +result = project.update_o_auth2_tik_tok( + client_id: '<CLIENT_ID>', # optional + client_secret: '<CLIENT_SECRET>', # optional + enabled: false # optional +) +``` diff --git a/docs/examples/project/update-o-auth-2-webflow.md b/docs/examples/project/update-o-auth-2-webflow.md new file mode 100644 index 00000000..22b17c71 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-webflow.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +project = Project.new(client) + +result = project.update_o_auth2_webflow( + client_id: '<CLIENT_ID>', # optional + client_secret: '<CLIENT_SECRET>', # optional + enabled: false # optional +) +``` diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md index 2fbd5fed..7c7c190d 100644 --- a/docs/examples/project/update-o-auth-2-zoho.md +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -2,6 +2,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint @@ -13,6 +14,7 @@ project = Project.new(client) result = project.update_o_auth2_zoho( client_id: '<CLIENT_ID>', # optional client_secret: '<CLIENT_SECRET>', # optional + prompt: [ProjectOAuth2ZohoPrompt::CONSENT], # optional enabled: false # optional ) ``` diff --git a/docs/examples/project/update-passkey-policy.md b/docs/examples/project/update-passkey-policy.md new file mode 100644 index 00000000..fd92c76a --- /dev/null +++ b/docs/examples/project/update-passkey-policy.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +project = Project.new(client) + +result = project.update_passkey_policy( + rp_id: '<RP_ID>' +) +``` diff --git a/docs/examples/project/update-password-pwned-policy.md b/docs/examples/project/update-password-pwned-policy.md new file mode 100644 index 00000000..abb2abb6 --- /dev/null +++ b/docs/examples/project/update-password-pwned-policy.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +project = Project.new(client) + +result = project.update_password_pwned_policy( + enabled: false, # optional + sessions: false, # optional + users: false # optional +) +``` diff --git a/docs/examples/project/update-password-rotation-policy.md b/docs/examples/project/update-password-rotation-policy.md new file mode 100644 index 00000000..d337bed6 --- /dev/null +++ b/docs/examples/project/update-password-rotation-policy.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +project = Project.new(client) + +result = project.update_password_rotation_policy( + enabled: false, # optional + max_age: 86400 # optional +) +``` diff --git a/docs/examples/sites/list-frameworks.md b/docs/examples/sites/list-frameworks.md index a33303a2..7b8b8f56 100644 --- a/docs/examples/sites/list-frameworks.md +++ b/docs/examples/sites/list-frameworks.md @@ -10,5 +10,7 @@ client = Client.new sites = Sites.new(client) -result = sites.list_frameworks() +result = sites.list_frameworks( + total: false # optional +) ``` diff --git a/docs/examples/sites/list-specifications.md b/docs/examples/sites/list-specifications.md index 9ed8d001..1f816b90 100644 --- a/docs/examples/sites/list-specifications.md +++ b/docs/examples/sites/list-specifications.md @@ -11,6 +11,7 @@ client = Client.new sites = Sites.new(client) result = sites.list_specifications( - type: 'runtimes' # optional + type: 'runtimes', # optional + total: false # optional ) ``` diff --git a/docs/examples/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: '<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: '<TABLE_ID>', key: '<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: '<DATABASE_ID>', table_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: '<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: '<DATABASE_ID>', table_id: '<TABLE_ID>', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"<ROW_ID>\"]}"], # optional transaction_id: '<TRANSACTION_ID>' # optional ) ``` diff --git a/docs/examples/tablesdb/list-transactions.md b/docs/examples/tablesdb/list-transactions.md index f8800dd7..de6a2389 100644 --- a/docs/examples/tablesdb/list-transactions.md +++ b/docs/examples/tablesdb/list-transactions.md @@ -11,6 +11,7 @@ client = Client.new tables_db = TablesDB.new(client) result = tables_db.list_transactions( - queries: [] # optional + queries: [], # optional + total: false # optional ) ``` diff --git a/docs/examples/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: '<DATABASE_ID>', table_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: '<TRANSACTION_ID>' # optional ) ``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 7df704e7..8c865361 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -12,7 +12,8 @@ teams = Teams.new(client) result = teams.create_membership( team_id: '<TEAM_ID>', - roles: [], + roles: ["editor"], + membership_id: '<MEMBERSHIP_ID>', # optional email: 'email@example.com', # optional user_id: '<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: '<TEAM_ID>', membership_id: '<MEMBERSHIP_ID>', - roles: [] + roles: ["editor"] ) ``` diff --git a/docs/examples/users/delete-passkey.md b/docs/examples/users/delete-passkey.md new file mode 100644 index 00000000..b07052f2 --- /dev/null +++ b/docs/examples/users/delete-passkey.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users.new(client) + +result = users.delete_passkey( + user_id: '<USER_ID>', + passkey_id: '<PASSKEY_ID>' +) +``` diff --git a/docs/examples/users/get-passkey.md b/docs/examples/users/get-passkey.md new file mode 100644 index 00000000..4c72d532 --- /dev/null +++ b/docs/examples/users/get-passkey.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users.new(client) + +result = users.get_passkey( + user_id: '<USER_ID>', + passkey_id: '<PASSKEY_ID>' +) +``` diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-passkeys.md similarity index 92% rename from docs/examples/users/list-logs.md rename to docs/examples/users/list-passkeys.md index dd9809e3..21faf80b 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/users/list-passkeys.md @@ -10,7 +10,7 @@ client = Client.new users = Users.new(client) -result = users.list_logs( +result = users.list_passkeys( user_id: '<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: '<USER_ID>', - labels: [] + labels: ["subscriber"] ) ``` diff --git a/docs/examples/users/update-passkey.md b/docs/examples/users/update-passkey.md new file mode 100644 index 00000000..e367aa9d --- /dev/null +++ b/docs/examples/users/update-passkey.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +users = Users.new(client) + +result = users.update_passkey( + user_id: '<USER_ID>', + passkey_id: '<PASSKEY_ID>', + name: '<NAME>' +) +``` 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: '<DATABASE_ID>', collection_id: '<COLLECTION_ID>', name: '<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: '<DATABASE_ID>', collection_id: '<COLLECTION_ID>', - documents: [], + documents: [ + { + "$id": "example1", + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } + } + ], transaction_id: '<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: '<COLLECTION_ID>', key: '<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": "<COLLECTION_ID>", "documentId": "<DOCUMENT_ID>", "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: '<DATABASE_ID>', collection_id: '<COLLECTION_ID>', - queries: [], # optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"<DOCUMENT_ID>\"]}"], # optional transaction_id: '<TRANSACTION_ID>' # optional ) ``` diff --git a/docs/examples/vectorsdb/list-transactions.md b/docs/examples/vectorsdb/list-transactions.md index 9c2182da..2db8f34b 100644 --- a/docs/examples/vectorsdb/list-transactions.md +++ b/docs/examples/vectorsdb/list-transactions.md @@ -11,6 +11,7 @@ client = Client.new vectors_db = VectorsDB.new(client) result = vectors_db.list_transactions( - queries: [] # optional + queries: [], # optional + total: false # optional ) ``` diff --git a/docs/examples/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: '<DATABASE_ID>', collection_id: '<COLLECTION_ID>', name: '<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: '<DATABASE_ID>', collection_id: '<COLLECTION_ID>', - documents: [], + documents: [ + { + "$id": "example1", + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } + } + ], transaction_id: '<TRANSACTION_ID>' # optional ) ``` diff --git a/docs/examples/waf/create-bypass-rule.md b/docs/examples/waf/create-bypass-rule.md new file mode 100644 index 00000000..084ce800 --- /dev/null +++ b/docs/examples/waf/create-bypass-rule.md @@ -0,0 +1,23 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +waf = Waf.new(client) + +result = waf.create_bypass_rule( + rule_id: '<RULE_ID>', + resource_type: 'api', + name: '<NAME>', + resource_id: '<RESOURCE_ID>', # optional + description: '<DESCRIPTION>', # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # optional +) +``` diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md new file mode 100644 index 00000000..cc4545ec --- /dev/null +++ b/docs/examples/waf/create-challenge-rule.md @@ -0,0 +1,26 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +waf = Waf.new(client) + +result = waf.create_challenge_rule( + rule_id: '<RULE_ID>', + resource_type: 'api', + name: '<NAME>', + resource_id: '<RESOURCE_ID>', # optional + description: '<DESCRIPTION>', # optional + challenge_type: 'compute', # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [], # optional + difficulty: 1, # optional + ttl: 900 # optional +) +``` diff --git a/docs/examples/waf/create-deny-rule.md b/docs/examples/waf/create-deny-rule.md new file mode 100644 index 00000000..653f3786 --- /dev/null +++ b/docs/examples/waf/create-deny-rule.md @@ -0,0 +1,23 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +waf = Waf.new(client) + +result = waf.create_deny_rule( + rule_id: '<RULE_ID>', + resource_type: 'api', + name: '<NAME>', + resource_id: '<RESOURCE_ID>', # optional + description: '<DESCRIPTION>', # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # optional +) +``` diff --git a/docs/examples/waf/create-rate-limit-rule.md b/docs/examples/waf/create-rate-limit-rule.md new file mode 100644 index 00000000..6b188b9f --- /dev/null +++ b/docs/examples/waf/create-rate-limit-rule.md @@ -0,0 +1,28 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +waf = Waf.new(client) + +result = waf.create_rate_limit_rule( + rule_id: '<RULE_ID>', + resource_type: 'api', + name: '<NAME>', + limit: 1, + interval: 1, + resource_id: '<RESOURCE_ID>', # optional + description: '<DESCRIPTION>', # optional + key: 'ip', # optional + strategy: 'fixedWindow', # optional + max_bucket_size: 1, # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # optional +) +``` diff --git a/docs/examples/waf/create-redirect-rule.md b/docs/examples/waf/create-redirect-rule.md new file mode 100644 index 00000000..ffa441bb --- /dev/null +++ b/docs/examples/waf/create-redirect-rule.md @@ -0,0 +1,25 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +waf = Waf.new(client) + +result = waf.create_redirect_rule( + rule_id: '<RULE_ID>', + resource_type: 'api', + name: '<NAME>', + location: '<LOCATION>', + status_code: 300, + resource_id: '<RESOURCE_ID>', # optional + description: '<DESCRIPTION>', # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # optional +) +``` diff --git a/docs/examples/waf/delete-rule.md b/docs/examples/waf/delete-rule.md new file mode 100644 index 00000000..6f1bb035 --- /dev/null +++ b/docs/examples/waf/delete-rule.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +waf = Waf.new(client) + +result = waf.delete_rule( + rule_id: '<RULE_ID>' +) +``` diff --git a/docs/examples/waf/get-rule.md b/docs/examples/waf/get-rule.md new file mode 100644 index 00000000..c6929bf8 --- /dev/null +++ b/docs/examples/waf/get-rule.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +waf = Waf.new(client) + +result = waf.get_rule( + rule_id: '<RULE_ID>' +) +``` diff --git a/docs/examples/waf/list-rules.md b/docs/examples/waf/list-rules.md new file mode 100644 index 00000000..3c925cc9 --- /dev/null +++ b/docs/examples/waf/list-rules.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +waf = Waf.new(client) + +result = waf.list_rules( + queries: [], # optional + search: '<SEARCH>', # optional + total: false # optional +) +``` diff --git a/docs/examples/waf/update-bypass-rule.md b/docs/examples/waf/update-bypass-rule.md new file mode 100644 index 00000000..8e691de2 --- /dev/null +++ b/docs/examples/waf/update-bypass-rule.md @@ -0,0 +1,23 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +waf = Waf.new(client) + +result = waf.update_bypass_rule( + rule_id: '<RULE_ID>', + resource_type: 'api', # optional + resource_id: '<RESOURCE_ID>', # optional + name: '<NAME>', # optional + description: '<DESCRIPTION>', # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # optional +) +``` diff --git a/docs/examples/waf/update-challenge-rule.md b/docs/examples/waf/update-challenge-rule.md new file mode 100644 index 00000000..19b117fe --- /dev/null +++ b/docs/examples/waf/update-challenge-rule.md @@ -0,0 +1,26 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +waf = Waf.new(client) + +result = waf.update_challenge_rule( + rule_id: '<RULE_ID>', + resource_type: 'api', # optional + resource_id: '<RESOURCE_ID>', # optional + name: '<NAME>', # optional + description: '<DESCRIPTION>', # optional + challenge_type: 'compute', # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [], # optional + difficulty: 1, # optional + ttl: 900 # optional +) +``` diff --git a/docs/examples/waf/update-deny-rule.md b/docs/examples/waf/update-deny-rule.md new file mode 100644 index 00000000..f623be16 --- /dev/null +++ b/docs/examples/waf/update-deny-rule.md @@ -0,0 +1,23 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +waf = Waf.new(client) + +result = waf.update_deny_rule( + rule_id: '<RULE_ID>', + resource_type: 'api', # optional + resource_id: '<RESOURCE_ID>', # optional + name: '<NAME>', # optional + description: '<DESCRIPTION>', # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # optional +) +``` diff --git a/docs/examples/waf/update-rate-limit-rule.md b/docs/examples/waf/update-rate-limit-rule.md new file mode 100644 index 00000000..2eb58465 --- /dev/null +++ b/docs/examples/waf/update-rate-limit-rule.md @@ -0,0 +1,27 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +waf = Waf.new(client) + +result = waf.update_rate_limit_rule( + rule_id: '<RULE_ID>', + resource_type: 'api', # optional + resource_id: '<RESOURCE_ID>', # optional + name: '<NAME>', # optional + description: '<DESCRIPTION>', # optional + limit: 1, # optional + interval: 1, # optional + key: 'ip', # optional + max_bucket_size: 1, # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # optional +) +``` diff --git a/docs/examples/waf/update-redirect-rule.md b/docs/examples/waf/update-redirect-rule.md new file mode 100644 index 00000000..3ebfef30 --- /dev/null +++ b/docs/examples/waf/update-redirect-rule.md @@ -0,0 +1,25 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_key('<YOUR_API_KEY>') # Your secret API key + +waf = Waf.new(client) + +result = waf.update_redirect_rule( + rule_id: '<RULE_ID>', + resource_type: 'api', # optional + resource_id: '<RESOURCE_ID>', # optional + name: '<NAME>', # optional + description: '<DESCRIPTION>', # optional + location: '<LOCATION>', # optional + status_code: 300, # optional + priority: -100000, # optional + enabled: false, # optional + conditions: [] # 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: '<WEBHOOK_ID>', url: 'https://example.com/webhook', name: '<NAME>', - events: [], + events: ["users.*.create"], enabled: false, # optional tls: false, # optional auth_username: '<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: '<WEBHOOK_ID>', name: '<NAME>', url: 'https://example.com/webhook', - events: [], + events: ["users.*.create"], enabled: false, # optional tls: false, # optional auth_username: '<AUTH_USERNAME>', # optional diff --git a/lib/appwrite.rb b/lib/appwrite.rb index 6e6c992f..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' @@ -120,6 +119,7 @@ require_relative 'appwrite/models/algo_scrypt' require_relative 'appwrite/models/algo_scrypt_modified' require_relative 'appwrite/models/algo_argon2' +require_relative 'appwrite/models/account' require_relative 'appwrite/models/preferences' require_relative 'appwrite/models/session' require_relative 'appwrite/models/identity' @@ -146,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' @@ -163,6 +162,7 @@ require_relative 'appwrite/models/o_auth2_yandex' require_relative 'appwrite/models/o_auth2_x' require_relative 'appwrite/models/o_auth2_word_press' +require_relative 'appwrite/models/o_auth2_webflow' require_relative 'appwrite/models/o_auth2_twitch' require_relative 'appwrite/models/o_auth2_stripe' require_relative 'appwrite/models/o_auth2_spotify' @@ -192,11 +192,15 @@ require_relative 'appwrite/models/o_auth2_apple' require_relative 'appwrite/models/o_auth2_microsoft' require_relative 'appwrite/models/o_auth2_resend' +require_relative 'appwrite/models/o_auth2_tik_tok' +require_relative 'appwrite/models/o_auth2_kakao' require_relative 'appwrite/models/o_auth2_provider_list' require_relative 'appwrite/models/policy_password_dictionary' require_relative 'appwrite/models/policy_password_history' require_relative 'appwrite/models/policy_password_strength' require_relative 'appwrite/models/policy_password_personal_data' +require_relative 'appwrite/models/policy_password_pwned' +require_relative 'appwrite/models/policy_password_rotation' require_relative 'appwrite/models/policy_session_alert' require_relative 'appwrite/models/policy_session_duration' require_relative 'appwrite/models/policy_session_invalidation' @@ -204,6 +208,11 @@ require_relative 'appwrite/models/policy_user_limit' 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' @@ -222,6 +231,10 @@ require_relative 'appwrite/models/email_template' require_relative 'appwrite/models/mfa_challenge' require_relative 'appwrite/models/mfa_challenge_secret' +require_relative 'appwrite/models/token_secret' +require_relative 'appwrite/models/passkey' +require_relative 'appwrite/models/passkey_challenge' +require_relative 'appwrite/models/passkey_list' require_relative 'appwrite/models/mfa_recovery_codes' require_relative 'appwrite/models/mfa_type' require_relative 'appwrite/models/mfa_factors' @@ -256,6 +269,10 @@ require_relative 'appwrite/models/dedicated_database_execution_column' require_relative 'appwrite/models/dedicated_database_restoration' require_relative 'appwrite/models/database_status' +require_relative 'appwrite/models/dns_record' +require_relative 'appwrite/models/domain' +require_relative 'appwrite/models/domain_price' +require_relative 'appwrite/models/domain_transfer_status' require_relative 'appwrite/models/dedicated_database_extensions' require_relative 'appwrite/models/dedicated_database_member' require_relative 'appwrite/models/dedicated_database_operation' @@ -265,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' @@ -276,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' @@ -294,8 +306,15 @@ require_relative 'appwrite/models/oauth2_device_authorization' require_relative 'appwrite/models/oauth2_par' require_relative 'appwrite/models/oauth2_token' +require_relative 'appwrite/models/oauth2_introspection' require_relative 'appwrite/models/oauth2_consent' require_relative 'appwrite/models/oauth2_consent_token' +require_relative 'appwrite/models/waf_rule_bypass' +require_relative 'appwrite/models/waf_rule_deny' +require_relative 'appwrite/models/waf_rule_challenge' +require_relative 'appwrite/models/waf_rule_rate_limit' +require_relative 'appwrite/models/waf_rule_redirect' +require_relative 'appwrite/models/waf_rule_list' require_relative 'appwrite/models/oauth2_project' require_relative 'appwrite/models/oauth2_organization' require_relative 'appwrite/models/oauth2_project_list' @@ -308,6 +327,9 @@ require_relative 'appwrite/models/backup_restoration_list' require_relative 'appwrite/models/database_migration_list' require_relative 'appwrite/models/dedicated_database_list' +require_relative 'appwrite/models/dns_records_list' +require_relative 'appwrite/models/domain_prices_list' +require_relative 'appwrite/models/domains_list' require_relative 'appwrite/models/apps_list' require_relative 'appwrite/models/app_secret_list' require_relative 'appwrite/models/app_scope_list' @@ -316,6 +338,7 @@ require_relative 'appwrite/enums/authenticator_type' require_relative 'appwrite/enums/authentication_factor' +require_relative 'appwrite/enums/id_token_provider' require_relative 'appwrite/enums/o_auth_provider' require_relative 'appwrite/enums/browser' require_relative 'appwrite/enums/credit_card' @@ -330,6 +353,7 @@ require_relative 'appwrite/enums/databases_index_type' require_relative 'appwrite/enums/order_by' require_relative 'appwrite/enums/documents_db_index_type' +require_relative 'appwrite/enums/domain_registration_type' require_relative 'appwrite/enums/embedding_model' require_relative 'appwrite/enums/runtime' require_relative 'appwrite/enums/project_key_scopes' @@ -339,11 +363,18 @@ 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' +require_relative 'appwrite/enums/project_o_auth2_discord_prompt' +require_relative 'appwrite/enums/project_o_auth2_git_hub_prompt' require_relative 'appwrite/enums/project_o_auth2_google_prompt' +require_relative 'appwrite/enums/project_o_auth2_kakao_prompt' +require_relative 'appwrite/enums/project_o_auth2_microsoft_prompt' require_relative 'appwrite/enums/project_o_auth2_oidc_prompt' +require_relative 'appwrite/enums/project_o_auth2_okta_prompt' +require_relative 'appwrite/enums/project_o_auth2_salesforce_prompt' +require_relative 'appwrite/enums/project_o_auth2_zoho_prompt' require_relative 'appwrite/enums/project_o_auth_provider_id' require_relative 'appwrite/enums/project_policy_id' require_relative 'appwrite/enums/project_protocol_id' @@ -372,13 +403,23 @@ require_relative 'appwrite/enums/execution_resource_type' require_relative 'appwrite/enums/execution_trigger' require_relative 'appwrite/enums/execution_status' +require_relative 'appwrite/enums/o_auth2_github_prompt' +require_relative 'appwrite/enums/o_auth2_discord_prompt' require_relative 'appwrite/enums/o_auth2_google_prompt' +require_relative 'appwrite/enums/o_auth2_zoho_prompt' +require_relative 'appwrite/enums/o_auth2_salesforce_prompt' +require_relative 'appwrite/enums/o_auth2_auth0_prompt' require_relative 'appwrite/enums/o_auth2_oidc_prompt' +require_relative 'appwrite/enums/o_auth2_okta_prompt' +require_relative 'appwrite/enums/o_auth2_microsoft_prompt' +require_relative 'appwrite/enums/o_auth2_kakao_prompt' require_relative 'appwrite/enums/platform_type' require_relative 'appwrite/enums/proxy_rule_deployment_resource_type' require_relative 'appwrite/enums/proxy_rule_status' require_relative 'appwrite/enums/message_status' require_relative 'appwrite/enums/billing_plan_group' +require_relative 'appwrite/enums/domain_transfer_status_enum' +require_relative 'appwrite/enums/waf_rule_action' require_relative 'appwrite/services/account' require_relative 'appwrite/services/activities' @@ -387,6 +428,7 @@ require_relative 'appwrite/services/backups' require_relative 'appwrite/services/databases' require_relative 'appwrite/services/documents_db' +require_relative 'appwrite/services/domains' require_relative 'appwrite/services/embeddings' require_relative 'appwrite/services/functions' require_relative 'appwrite/services/graphql' @@ -408,4 +450,5 @@ require_relative 'appwrite/services/tokens' require_relative 'appwrite/services/users' require_relative 'appwrite/services/vectors_db' +require_relative 'appwrite/services/waf' require_relative 'appwrite/services/webhooks' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index 63fb784b..aa9df3d3 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.2.0', - 'X-Appwrite-Response-Format' => '2.0.0' + 'x-sdk-version' => '29.0.0', + 'X-Appwrite-Response-Format' => '2.4.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. @@ -278,10 +264,21 @@ def chunked_upload( param_name: '', id_param_name: nil, on_progress: nil, - response_type: nil + response_type: nil, + method: 'POST' ) input_file = params[param_name.to_sym] + 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) @@ -289,13 +286,13 @@ 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 params[param_name.to_sym] = input_file return call( - method: 'POST', + method: method, path: path, headers: headers, params: params, @@ -359,7 +356,7 @@ def chunked_upload( chunk_headers['x-appwrite-id'] = current_upload_id if current_upload_id call( - method: 'POST', + method: method, path: path, headers: chunk_headers, params: chunk_params, @@ -520,6 +517,10 @@ def fetch( raise Appwrite::Exception.new(response.body, response.code, response, response.body) end + if response_type == "text" + return decode_text(response) + end + if response.respond_to?("body_permitted?") return response.body if response.body_permitted? end @@ -527,9 +528,22 @@ def fetch( return response end + def decode_text(response) + charset = response.type_params['charset'] || 'utf-8' + encoding = begin + Encoding.find(charset) + rescue ArgumentError + Encoding::UTF_8 + end + + String.new(response.body.to_s, encoding: encoding).encode(Encoding::UTF_8) + end + def encode_form_data(value, key = nil) case value when Hash + 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 343b49a8..59fde6e6 100644 --- a/lib/appwrite/enums/billing_plan_group.rb +++ b/lib/appwrite/enums/billing_plan_group.rb @@ -1,7 +1,8 @@ module Appwrite module Enums module BillingPlanGroup - STARTER = 'starter' + FREE = 'free' + START = 'start' PRO = 'pro' SCALE = 'scale' end diff --git a/lib/appwrite/enums/build_runtime.rb b/lib/appwrite/enums/build_runtime.rb index 0f1a8803..cb868c9c 100644 --- a/lib/appwrite/enums/build_runtime.rb +++ b/lib/appwrite/enums/build_runtime.rb @@ -52,6 +52,7 @@ module BuildRuntime DART_3_10 = 'dart-3.10' DART_3_11 = 'dart-3.11' DART_3_12 = 'dart-3.12' + DART_3_13 = 'dart-3.13' DOTNET_6_0 = 'dotnet-6.0' DOTNET_7_0 = 'dotnet-7.0' DOTNET_8_0 = 'dotnet-8.0' @@ -94,6 +95,7 @@ module BuildRuntime FLUTTER_3_38 = 'flutter-3.38' FLUTTER_3_41 = 'flutter-3.41' FLUTTER_3_44 = 'flutter-3.44' + FLUTTER_3_47 = 'flutter-3.47' end end end diff --git a/lib/appwrite/enums/domain_registration_type.rb b/lib/appwrite/enums/domain_registration_type.rb new file mode 100644 index 00000000..81869b83 --- /dev/null +++ b/lib/appwrite/enums/domain_registration_type.rb @@ -0,0 +1,10 @@ +module Appwrite + module Enums + module DomainRegistrationType + NEW = 'new' + TRANSFER = 'transfer' + RENEWAL = 'renewal' + TRADE = 'trade' + end + end +end diff --git a/lib/appwrite/enums/domain_transfer_status_enum.rb b/lib/appwrite/enums/domain_transfer_status_enum.rb new file mode 100644 index 00000000..99eeb20d --- /dev/null +++ b/lib/appwrite/enums/domain_transfer_status_enum.rb @@ -0,0 +1,14 @@ +module Appwrite + module Enums + module DomainTransferStatusEnum + TRANSFERRABLE = 'transferrable' + NOT_TRANSFERRABLE = 'not_transferrable' + PENDING_OWNER = 'pending_owner' + PENDING_ADMIN = 'pending_admin' + PENDING_REGISTRY = 'pending_registry' + COMPLETED = 'completed' + CANCELLED = 'cancelled' + SERVICE_UNAVAILABLE = 'service_unavailable' + end + end +end diff --git a/lib/appwrite/enums/framework.rb b/lib/appwrite/enums/framework.rb index 6beab64f..bc51bd04 100644 --- a/lib/appwrite/enums/framework.rb +++ b/lib/appwrite/enums/framework.rb @@ -13,6 +13,7 @@ module Framework REMIX = 'remix' LYNX = 'lynx' FLUTTER = 'flutter' + JASPR = 'jaspr' REACT_NATIVE = 'react-native' VITE = 'vite' OTHER = 'other' diff --git a/lib/appwrite/enums/id_token_provider.rb b/lib/appwrite/enums/id_token_provider.rb new file mode 100644 index 00000000..8513d5b0 --- /dev/null +++ b/lib/appwrite/enums/id_token_provider.rb @@ -0,0 +1,8 @@ +module Appwrite + module Enums + module IdTokenProvider + APPLE = 'apple' + GOOGLE = 'google' + end + end +end diff --git a/lib/appwrite/enums/image_gravity.rb b/lib/appwrite/enums/image_gravity.rb index 6eb0b5b1..705778a4 100644 --- a/lib/appwrite/enums/image_gravity.rb +++ b/lib/appwrite/enums/image_gravity.rb @@ -1,6 +1,7 @@ module Appwrite module Enums module ImageGravity + AUTO = 'auto' CENTER = 'center' TOP_LEFT = 'top-left' TOP = 'top' diff --git a/lib/appwrite/enums/o_auth2_auth0_prompt.rb b/lib/appwrite/enums/o_auth2_auth0_prompt.rb new file mode 100644 index 00000000..e53dde5b --- /dev/null +++ b/lib/appwrite/enums/o_auth2_auth0_prompt.rb @@ -0,0 +1,9 @@ +module Appwrite + module Enums + module OAuth2Auth0Prompt + NONE = 'none' + LOGIN = 'login' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/o_auth2_discord_prompt.rb b/lib/appwrite/enums/o_auth2_discord_prompt.rb new file mode 100644 index 00000000..87d52730 --- /dev/null +++ b/lib/appwrite/enums/o_auth2_discord_prompt.rb @@ -0,0 +1,8 @@ +module Appwrite + module Enums + module OAuth2DiscordPrompt + NONE = 'none' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/o_auth2_github_prompt.rb b/lib/appwrite/enums/o_auth2_github_prompt.rb new file mode 100644 index 00000000..8c662b16 --- /dev/null +++ b/lib/appwrite/enums/o_auth2_github_prompt.rb @@ -0,0 +1,7 @@ +module Appwrite + module Enums + module OAuth2GithubPrompt + SELECT_ACCOUNT = 'select_account' + end + end +end diff --git a/lib/appwrite/enums/o_auth2_kakao_prompt.rb b/lib/appwrite/enums/o_auth2_kakao_prompt.rb new file mode 100644 index 00000000..a4597c3d --- /dev/null +++ b/lib/appwrite/enums/o_auth2_kakao_prompt.rb @@ -0,0 +1,10 @@ +module Appwrite + module Enums + module OAuth2KakaoPrompt + NONE = 'none' + LOGIN = 'login' + CREATE = 'create' + SELECT_ACCOUNT = 'select_account' + end + end +end diff --git a/lib/appwrite/enums/o_auth2_microsoft_prompt.rb b/lib/appwrite/enums/o_auth2_microsoft_prompt.rb new file mode 100644 index 00000000..24e04c48 --- /dev/null +++ b/lib/appwrite/enums/o_auth2_microsoft_prompt.rb @@ -0,0 +1,10 @@ +module Appwrite + module Enums + module OAuth2MicrosoftPrompt + NONE = 'none' + LOGIN = 'login' + CONSENT = 'consent' + SELECT_ACCOUNT = 'select_account' + end + end +end diff --git a/lib/appwrite/enums/o_auth2_okta_prompt.rb b/lib/appwrite/enums/o_auth2_okta_prompt.rb new file mode 100644 index 00000000..773af5e9 --- /dev/null +++ b/lib/appwrite/enums/o_auth2_okta_prompt.rb @@ -0,0 +1,9 @@ +module Appwrite + module Enums + module OAuth2OktaPrompt + NONE = 'none' + LOGIN = 'login' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/o_auth2_salesforce_prompt.rb b/lib/appwrite/enums/o_auth2_salesforce_prompt.rb new file mode 100644 index 00000000..9ffba0ed --- /dev/null +++ b/lib/appwrite/enums/o_auth2_salesforce_prompt.rb @@ -0,0 +1,8 @@ +module Appwrite + module Enums + module OAuth2SalesforcePrompt + LOGIN = 'login' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/o_auth2_zoho_prompt.rb b/lib/appwrite/enums/o_auth2_zoho_prompt.rb new file mode 100644 index 00000000..88cabea6 --- /dev/null +++ b/lib/appwrite/enums/o_auth2_zoho_prompt.rb @@ -0,0 +1,7 @@ +module Appwrite + module Enums + module OAuth2ZohoPrompt + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/o_auth_provider.rb b/lib/appwrite/enums/o_auth_provider.rb index 13025937..27c112c6 100644 --- a/lib/appwrite/enums/o_auth_provider.rb +++ b/lib/appwrite/enums/o_auth_provider.rb @@ -23,6 +23,7 @@ module OAuthProvider GITLAB = 'gitlab' GOOGLE = 'google' HUGGINGFACE = 'huggingface' + KAKAO = 'kakao' KEYCLOAK = 'keycloak' KICK = 'kick' LINKEDIN = 'linkedin' @@ -38,9 +39,11 @@ module OAuthProvider SLACK = 'slack' SPOTIFY = 'spotify' STRIPE = 'stripe' + TIKTOK = 'tiktok' TRADESHIFT = 'tradeshift' TRADESHIFTBOX = 'tradeshiftBox' TWITCH = 'twitch' + WEBFLOW = 'webflow' WORDPRESS = 'wordpress' X = 'x' YAHOO = 'yahoo' diff --git a/lib/appwrite/enums/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/project_auth_method_id.rb b/lib/appwrite/enums/project_auth_method_id.rb index da27cbb7..6256d8f8 100644 --- a/lib/appwrite/enums/project_auth_method_id.rb +++ b/lib/appwrite/enums/project_auth_method_id.rb @@ -8,6 +8,7 @@ module ProjectAuthMethodId INVITES = 'invites' JWT = 'jwt' PHONE = 'phone' + PASSKEY = 'passkey' end end end diff --git a/lib/appwrite/enums/project_email_template_id.rb b/lib/appwrite/enums/project_email_template_id.rb index bfe21974..525eaabf 100644 --- a/lib/appwrite/enums/project_email_template_id.rb +++ b/lib/appwrite/enums/project_email_template_id.rb @@ -8,6 +8,8 @@ module ProjectEmailTemplateId MFACHALLENGE = 'mfaChallenge' SESSIONALERT = 'sessionAlert' OTPSESSION = 'otpSession' + OTPVERIFICATION = 'otpVerification' + OTPRECOVERY = 'otpRecovery' end end end diff --git a/lib/appwrite/enums/project_key_scopes.rb b/lib/appwrite/enums/project_key_scopes.rb index 388f0004..2a30d3a3 100644 --- a/lib/appwrite/enums/project_key_scopes.rb +++ b/lib/appwrite/enums/project_key_scopes.rb @@ -91,6 +91,7 @@ module ProjectKeyScopes WEBHOOKS_WRITE = 'webhooks.write' LOCALE_READ = 'locale.read' AVATARS_READ = 'avatars.read' + AVATARS_WRITE = 'avatars.write' HEALTH_READ = 'health.read' ASSISTANT_READ = 'assistant.read' MIGRATIONS_READ = 'migrations.read' @@ -105,6 +106,7 @@ module ProjectKeyScopes REPORTS_WRITE = 'reports.write' PRESENCES_READ = 'presences.read' PRESENCES_WRITE = 'presences.write' + DEDICATEDDATABASES_EXECUTE = 'dedicatedDatabases.execute' BACKUPS_POLICIES_READ = 'backups.policies.read' BACKUPS_POLICIES_WRITE = 'backups.policies.write' ARCHIVES_READ = 'archives.read' @@ -122,6 +124,8 @@ module ProjectKeyScopes OAUTH2_READ = 'oauth2.read' OAUTH2_WRITE = 'oauth2.write' OAUTH2_INTROSPECT = 'oauth2.introspect' + ANALYTICS_READ = 'analytics.read' + ANALYTICS_WRITE = 'analytics.write' end end end diff --git a/lib/appwrite/enums/project_o_auth2_auth0_prompt.rb b/lib/appwrite/enums/project_o_auth2_auth0_prompt.rb new file mode 100644 index 00000000..a41bc573 --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_auth0_prompt.rb @@ -0,0 +1,9 @@ +module Appwrite + module Enums + module ProjectOAuth2Auth0Prompt + NONE = 'none' + LOGIN = 'login' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth2_discord_prompt.rb b/lib/appwrite/enums/project_o_auth2_discord_prompt.rb new file mode 100644 index 00000000..d44b4b42 --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_discord_prompt.rb @@ -0,0 +1,8 @@ +module Appwrite + module Enums + module ProjectOAuth2DiscordPrompt + NONE = 'none' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth2_git_hub_prompt.rb b/lib/appwrite/enums/project_o_auth2_git_hub_prompt.rb new file mode 100644 index 00000000..d7cac0eb --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_git_hub_prompt.rb @@ -0,0 +1,7 @@ +module Appwrite + module Enums + module ProjectOAuth2GitHubPrompt + SELECT_ACCOUNT = 'select_account' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth2_kakao_prompt.rb b/lib/appwrite/enums/project_o_auth2_kakao_prompt.rb new file mode 100644 index 00000000..47e7fe96 --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_kakao_prompt.rb @@ -0,0 +1,10 @@ +module Appwrite + module Enums + module ProjectOAuth2KakaoPrompt + NONE = 'none' + LOGIN = 'login' + CREATE = 'create' + SELECT_ACCOUNT = 'select_account' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth2_microsoft_prompt.rb b/lib/appwrite/enums/project_o_auth2_microsoft_prompt.rb new file mode 100644 index 00000000..7eee1d0a --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_microsoft_prompt.rb @@ -0,0 +1,10 @@ +module Appwrite + module Enums + module ProjectOAuth2MicrosoftPrompt + NONE = 'none' + LOGIN = 'login' + CONSENT = 'consent' + SELECT_ACCOUNT = 'select_account' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth2_okta_prompt.rb b/lib/appwrite/enums/project_o_auth2_okta_prompt.rb new file mode 100644 index 00000000..c2ddeaf4 --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_okta_prompt.rb @@ -0,0 +1,9 @@ +module Appwrite + module Enums + module ProjectOAuth2OktaPrompt + NONE = 'none' + LOGIN = 'login' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth2_salesforce_prompt.rb b/lib/appwrite/enums/project_o_auth2_salesforce_prompt.rb new file mode 100644 index 00000000..90c1d432 --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_salesforce_prompt.rb @@ -0,0 +1,8 @@ +module Appwrite + module Enums + module ProjectOAuth2SalesforcePrompt + LOGIN = 'login' + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth2_zoho_prompt.rb b/lib/appwrite/enums/project_o_auth2_zoho_prompt.rb new file mode 100644 index 00000000..5b29253a --- /dev/null +++ b/lib/appwrite/enums/project_o_auth2_zoho_prompt.rb @@ -0,0 +1,7 @@ +module Appwrite + module Enums + module ProjectOAuth2ZohoPrompt + CONSENT = 'consent' + end + end +end diff --git a/lib/appwrite/enums/project_o_auth_provider_id.rb b/lib/appwrite/enums/project_o_auth_provider_id.rb index f6b4c97c..946de02f 100644 --- a/lib/appwrite/enums/project_o_auth_provider_id.rb +++ b/lib/appwrite/enums/project_o_auth_provider_id.rb @@ -23,6 +23,7 @@ module ProjectOAuthProviderId GITLAB = 'gitlab' GOOGLE = 'google' HUGGINGFACE = 'huggingface' + KAKAO = 'kakao' KEYCLOAK = 'keycloak' KICK = 'kick' LINKEDIN = 'linkedin' @@ -38,9 +39,11 @@ module ProjectOAuthProviderId SLACK = 'slack' SPOTIFY = 'spotify' STRIPE = 'stripe' + TIKTOK = 'tiktok' TRADESHIFT = 'tradeshift' TRADESHIFTBOX = 'tradeshiftBox' TWITCH = 'twitch' + WEBFLOW = 'webflow' WORDPRESS = 'wordpress' X = 'x' YAHOO = 'yahoo' diff --git a/lib/appwrite/enums/project_policy_id.rb b/lib/appwrite/enums/project_policy_id.rb index a844aaf0..34b8bbe1 100644 --- a/lib/appwrite/enums/project_policy_id.rb +++ b/lib/appwrite/enums/project_policy_id.rb @@ -5,6 +5,8 @@ module ProjectPolicyId PASSWORD_HISTORY = 'password-history' PASSWORD_STRENGTH = 'password-strength' PASSWORD_PERSONAL_DATA = 'password-personal-data' + PASSWORD_PWNED = 'password-pwned' + PASSWORD_ROTATION = 'password-rotation' SESSION_ALERT = 'session-alert' SESSION_DURATION = 'session-duration' SESSION_INVALIDATION = 'session-invalidation' @@ -16,6 +18,7 @@ module ProjectPolicyId DENY_DISPOSABLE_EMAIL = 'deny-disposable-email' DENY_FREE_EMAIL = 'deny-free-email' DENY_CORPORATE_EMAIL = 'deny-corporate-email' + PASSKEY = 'passkey' end end end diff --git a/lib/appwrite/enums/proxy_rule_deployment_resource_type.rb b/lib/appwrite/enums/proxy_rule_deployment_resource_type.rb index 89a76ba5..aac33df9 100644 --- a/lib/appwrite/enums/proxy_rule_deployment_resource_type.rb +++ b/lib/appwrite/enums/proxy_rule_deployment_resource_type.rb @@ -3,6 +3,7 @@ module Enums module ProxyRuleDeploymentResourceType FUNCTION = 'function' SITE = 'site' + DEDICATEDDATABASE = 'dedicatedDatabase' end end end diff --git a/lib/appwrite/enums/runtime.rb b/lib/appwrite/enums/runtime.rb index ed615ec7..e151066d 100644 --- a/lib/appwrite/enums/runtime.rb +++ b/lib/appwrite/enums/runtime.rb @@ -52,6 +52,7 @@ module Runtime DART_3_10 = 'dart-3.10' DART_3_11 = 'dart-3.11' DART_3_12 = 'dart-3.12' + DART_3_13 = 'dart-3.13' DOTNET_6_0 = 'dotnet-6.0' DOTNET_7_0 = 'dotnet-7.0' DOTNET_8_0 = 'dotnet-8.0' @@ -94,6 +95,7 @@ module Runtime FLUTTER_3_38 = 'flutter-3.38' FLUTTER_3_41 = 'flutter-3.41' FLUTTER_3_44 = 'flutter-3.44' + FLUTTER_3_47 = 'flutter-3.47' end end end diff --git a/lib/appwrite/enums/waf_rule_action.rb b/lib/appwrite/enums/waf_rule_action.rb new file mode 100644 index 00000000..3fa1389e --- /dev/null +++ b/lib/appwrite/enums/waf_rule_action.rb @@ -0,0 +1,11 @@ +module Appwrite + module Enums + module WafRuleAction + BYPASS = 'bypass' + DENY = 'deny' + CHALLENGE = 'challenge' + RATELIMIT = 'rateLimit' + REDIRECT = 'redirect' + end + end +end diff --git a/lib/appwrite/models/account.rb b/lib/appwrite/models/account.rb new file mode 100644 index 00000000..41e01622 --- /dev/null +++ b/lib/appwrite/models/account.rb @@ -0,0 +1,143 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class Account + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :registration + attr_reader :status + attr_reader :labels + attr_reader :password_update + attr_reader :email + attr_reader :phone + attr_reader :email_verification + attr_reader :email_canonical + attr_reader :email_is_free + attr_reader :email_is_disposable + attr_reader :email_is_corporate + attr_reader :email_is_canonical + attr_reader :password_pwned + attr_reader :phone_verification + attr_reader :mfa + attr_reader :prefs + attr_reader :targets + attr_reader :accessed_at + attr_reader :impersonator + attr_reader :impersonator_user_id + + def initialize( + id:, + created_at:, + updated_at:, + name:, + registration:, + status:, + labels:, + password_update:, + email:, + phone:, + email_verification:, + email_canonical:, + email_is_free:, + email_is_disposable:, + email_is_corporate:, + email_is_canonical:, + password_pwned:, + phone_verification:, + mfa:, + prefs:, + targets:, + accessed_at:, + impersonator:, + impersonator_user_id: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @registration = registration + @status = status + @labels = labels + @password_update = password_update + @email = email + @phone = phone + @email_verification = email_verification + @email_canonical = email_canonical + @email_is_free = email_is_free + @email_is_disposable = email_is_disposable + @email_is_corporate = email_is_corporate + @email_is_canonical = email_is_canonical + @password_pwned = password_pwned + @phone_verification = phone_verification + @mfa = mfa + @prefs = prefs + @targets = targets + @accessed_at = accessed_at + @impersonator = impersonator + @impersonator_user_id = impersonator_user_id + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "registration" => "", "status" => true, "labels" => [], "passwordUpdate" => "", "email" => "", "phone" => "", "emailVerification" => false, "phoneVerification" => false, "mfa" => false, "accessedAt" => "" }.merge(map) + Account.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + registration: map["registration"], + status: map["status"], + labels: map["labels"], + password_update: map["passwordUpdate"], + email: map["email"], + phone: map["phone"], + email_verification: map["emailVerification"], + email_canonical: map["emailCanonical"], + email_is_free: map["emailIsFree"], + email_is_disposable: map["emailIsDisposable"], + email_is_corporate: map["emailIsCorporate"], + email_is_canonical: map["emailIsCanonical"], + password_pwned: map["passwordPwned"], + phone_verification: map["phoneVerification"], + mfa: map["mfa"], + prefs: Preferences.from(map: map["prefs"]), + targets: map["targets"].map { |it| Target.from(map: it) }, + accessed_at: map["accessedAt"], + impersonator: map["impersonator"], + impersonator_user_id: map["impersonatorUserId"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "registration": @registration, + "status": @status, + "labels": @labels, + "passwordUpdate": @password_update, + "email": @email, + "phone": @phone, + "emailVerification": @email_verification, + "emailCanonical": @email_canonical, + "emailIsFree": @email_is_free, + "emailIsDisposable": @email_is_disposable, + "emailIsCorporate": @email_is_corporate, + "emailIsCanonical": @email_is_canonical, + "passwordPwned": @password_pwned, + "phoneVerification": @phone_verification, + "mfa": @mfa, + "prefs": @prefs.to_map, + "targets": @targets.map { |it| it.to_map }, + "accessedAt": @accessed_at, + "impersonator": @impersonator, + "impersonatorUserId": @impersonator_user_id + } + end + end + end +end diff --git a/lib/appwrite/models/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..3c68b5f2 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 }.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..ca177286 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" => "" }.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..0be7b830 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 }.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..ed9ec7e9 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 }.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..8872f8b6 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 }.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..6bb5f80d 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 }.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..caf3be61 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 }.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..7e92f842 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" => "", "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..7ed4f85a 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 }.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..9fa208fc 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" => "" }.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..902011b1 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 }.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..958594af 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" => "", "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..ce164abc 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 }.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..4102b824 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" => "", "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..2de910e2 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 }.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 cac6349d..8123b5eb 100644 --- a/lib/appwrite/models/billing_plan.rb +++ b/lib/appwrite/models/billing_plan.rb @@ -50,6 +50,7 @@ class BillingPlan attr_reader :email_branding attr_reader :requires_payment_method attr_reader :requires_billing_address + attr_reader :eligible_countries attr_reader :is_available attr_reader :self_service attr_reader :premium_support @@ -88,7 +89,7 @@ def initialize( storage:, image_transformations:, screenshots_generated:, - members:, + members: 0, webhooks:, waf_rules:, projects:, @@ -112,10 +113,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:, @@ -125,6 +126,7 @@ def initialize( email_branding:, requires_payment_method:, requires_billing_address:, + eligible_countries: [], is_available:, self_service:, premium_support:, @@ -138,10 +140,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:, @@ -199,6 +201,7 @@ def initialize( @email_branding = email_branding @requires_payment_method = requires_payment_method @requires_billing_address = requires_billing_address + @eligible_countries = eligible_countries @is_available = is_available @self_service = self_service @premium_support = premium_support @@ -228,6 +231,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, "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"], @@ -269,13 +273,14 @@ 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"], email_branding: map["emailBranding"], requires_payment_method: map["requiresPaymentMethod"], requires_billing_address: map["requiresBillingAddress"], + eligible_countries: map["eligibleCountries"], is_available: map["isAvailable"], self_service: map["selfService"], premium_support: map["premiumSupport"], @@ -347,13 +352,14 @@ 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, "emailBranding": @email_branding, "requiresPaymentMethod": @requires_payment_method, "requiresBillingAddress": @requires_billing_address, + "eligibleCountries": @eligible_countries, "isAvailable": @is_available, "selfService": @self_service, "premiumSupport": @premium_support, @@ -387,7 +393,8 @@ def to_map def validate_group(group) valid_group = [ - Appwrite::Enums::BillingPlanGroup::STARTER, + Appwrite::Enums::BillingPlanGroup::FREE, + Appwrite::Enums::BillingPlanGroup::START, Appwrite::Enums::BillingPlanGroup::PRO, Appwrite::Enums::BillingPlanGroup::SCALE, ] diff --git a/lib/appwrite/models/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..95d5f50c 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 }.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..d1b79309 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" => "", "databaseId" => "", "name" => "", "enabled" => true, "documentSecurity" => false, "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..69fcf202 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 }.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..7ef3181d 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" => "", "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..e898fe55 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 }.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..186e6249 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 }.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..7c999e70 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 }.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..6b8606a1 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 }.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..c30fe10c 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 }.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..e0b3767f 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 }.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..b53ea08d 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 }.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..e05caece 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 }.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 fd4b0b04..e9c87d7f 100644 --- a/lib/appwrite/models/dedicated_database.rb +++ b/lib/appwrite/models/dedicated_database.rb @@ -29,6 +29,9 @@ class DedicatedDatabase attr_reader :cpu attr_reader :memory attr_reader :storage + attr_reader :storage_status + attr_reader :storage_target_gb + attr_reader :storage_resize_started_at attr_reader :storage_class attr_reader :storage_max_gb attr_reader :node_pool @@ -80,6 +83,9 @@ def initialize( cpu:, memory:, storage:, + storage_status:, + storage_target_gb:, + storage_resize_started_at:, storage_class:, storage_max_gb:, node_pool:, @@ -130,6 +136,9 @@ def initialize( @cpu = cpu @memory = memory @storage = storage + @storage_status = storage_status + @storage_target_gb = storage_target_gb + @storage_resize_started_at = storage_resize_started_at @storage_class = storage_class @storage_max_gb = storage_max_gb @node_pool = node_pool @@ -156,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"], @@ -183,6 +193,9 @@ def self.from(map:) cpu: map["cpu"], memory: map["memory"], storage: map["storage"], + storage_status: map["storageStatus"], + storage_target_gb: map["storageTargetGb"], + storage_resize_started_at: map["storageResizeStartedAt"], storage_class: map["storageClass"], storage_max_gb: map["storageMaxGb"], node_pool: map["nodePool"], @@ -237,6 +250,9 @@ def to_map "cpu": @cpu, "memory": @memory, "storage": @storage, + "storageStatus": @storage_status, + "storageTargetGb": @storage_target_gb, + "storageResizeStartedAt": @storage_resize_started_at, "storageClass": @storage_class, "storageMaxGb": @storage_max_gb, "nodePool": @node_pool, diff --git a/lib/appwrite/models/dedicated_database_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..6963b5dd 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 }.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..855ce085 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 }.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..bd1a7277 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, "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..2fe59c6c 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" => [] }.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..2b71c4b6 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 }.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..9004e873 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 }.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..f32f88f3 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 }.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..56d5bb32 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 }.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 2448c2e1..2c0bc719 100644 --- a/lib/appwrite/models/dedicated_database_specification.rb +++ b/lib/appwrite/models/dedicated_database_specification.rb @@ -6,6 +6,10 @@ class DedicatedDatabaseSpecification attr_reader :slug attr_reader :name attr_reader :price + attr_reader :storage_overage_rate + attr_reader :bandwidth_overage_rate + attr_reader :replica_rate + attr_reader :pitr_rate attr_reader :cpu attr_reader :memory attr_reader :max_connections @@ -17,6 +21,10 @@ def initialize( slug:, name:, price:, + storage_overage_rate:, + bandwidth_overage_rate:, + replica_rate:, + pitr_rate:, cpu:, memory:, max_connections:, @@ -27,6 +35,10 @@ def initialize( @slug = slug @name = name @price = price + @storage_overage_rate = storage_overage_rate + @bandwidth_overage_rate = bandwidth_overage_rate + @replica_rate = replica_rate + @pitr_rate = pitr_rate @cpu = cpu @memory = memory @max_connections = max_connections @@ -36,10 +48,15 @@ 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"], price: map["price"], + storage_overage_rate: map["storageOverageRate"], + bandwidth_overage_rate: map["bandwidthOverageRate"], + replica_rate: map["replicaRate"], + pitr_rate: map["pitrRate"], cpu: map["cpu"], memory: map["memory"], max_connections: map["maxConnections"], @@ -54,6 +71,10 @@ def to_map "slug": @slug, "name": @name, "price": @price, + "storageOverageRate": @storage_overage_rate, + "bandwidthOverageRate": @bandwidth_overage_rate, + "replicaRate": @replica_rate, + "pitrRate": @pitr_rate, "cpu": @cpu, "memory": @memory, "maxConnections": @max_connections, diff --git a/lib/appwrite/models/dedicated_database_specification_list.rb b/lib/appwrite/models/dedicated_database_specification_list.rb index 206eec28..eaaa7e79 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 = { "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..d0e1b20c 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 }.merge(map) DeploymentList.new( total: map["total"], deployments: map["deployments"].map { |it| Deployment.from(map: it) } diff --git a/lib/appwrite/models/dns_record.rb b/lib/appwrite/models/dns_record.rb new file mode 100644 index 00000000..7dce4df7 --- /dev/null +++ b/lib/appwrite/models/dns_record.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class DnsRecord + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :type + attr_reader :name + attr_reader :value + attr_reader :ttl + attr_reader :priority + attr_reader :lock + attr_reader :weight + attr_reader :port + attr_reader :comment + + def initialize( + id:, + created_at:, + updated_at:, + type:, + name:, + value:, + ttl:, + priority:, + lock:, + weight:, + port:, + comment: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @type = type + @name = name + @value = value + @ttl = ttl + @priority = priority + @lock = lock + @weight = weight + @port = port + @comment = comment + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "type" => "", "name" => "", "value" => "", "ttl" => 3600, "priority" => 0, "lock" => false, "weight" => 0, "port" => 0, "comment" => "" }.merge(map) + DnsRecord.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + type: map["type"], + name: map["name"], + value: map["value"], + ttl: map["ttl"], + priority: map["priority"], + lock: map["lock"], + weight: map["weight"], + port: map["port"], + comment: map["comment"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "type": @type, + "name": @name, + "value": @value, + "ttl": @ttl, + "priority": @priority, + "lock": @lock, + "weight": @weight, + "port": @port, + "comment": @comment + } + end + end + end +end diff --git a/lib/appwrite/models/dns_records_list.rb b/lib/appwrite/models/dns_records_list.rb new file mode 100644 index 00000000..5c9ca4e2 --- /dev/null +++ b/lib/appwrite/models/dns_records_list.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class DnsRecordsList + attr_reader :total + attr_reader :dns_records + + def initialize( + total:, + dns_records: + ) + @total = total + @dns_records = dns_records + end + + def self.from(map:) + map = { "total" => 0 }.merge(map) + DnsRecordsList.new( + total: map["total"], + dns_records: map["dnsRecords"].map { |it| DnsRecord.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "dnsRecords": @dns_records.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/document.rb b/lib/appwrite/models/document.rb index 0cc8a466..87342b6c 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" => "" }.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..29da581c 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 }.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 new file mode 100644 index 00000000..8afe640c --- /dev/null +++ b/lib/appwrite/models/domain.rb @@ -0,0 +1,109 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class Domain + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :domain + attr_reader :registrar + attr_reader :nameservers + attr_reader :expire + attr_reader :renewal + attr_reader :auto_renewal + attr_reader :renewal_price + attr_reader :transfer_status + attr_reader :team_id + attr_reader :dns_records + + def initialize( + id:, + created_at:, + updated_at:, + domain:, + registrar:, + nameservers:, + expire:, + renewal:, + auto_renewal:, + renewal_price:, + transfer_status:, + team_id:, + dns_records: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @domain = domain + @registrar = registrar + @nameservers = nameservers + @expire = expire + @renewal = renewal + @auto_renewal = auto_renewal + @renewal_price = renewal_price + @transfer_status = transfer_status.nil? ? transfer_status : validate_transfer_status(transfer_status) + @team_id = team_id + @dns_records = dns_records + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "domain" => "", "registrar" => "", "nameservers" => "", "expire" => "", "renewal" => "", "autoRenewal" => false, "renewalPrice" => 0, "teamId" => "" }.merge(map) + Domain.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + domain: map["domain"], + registrar: map["registrar"], + nameservers: map["nameservers"], + expire: map["expire"], + renewal: map["renewal"], + auto_renewal: map["autoRenewal"], + renewal_price: map["renewalPrice"], + transfer_status: map["transferStatus"], + team_id: map["teamId"], + dns_records: map["dnsRecords"].map { |it| DnsRecord.from(map: it) } + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "domain": @domain, + "registrar": @registrar, + "nameservers": @nameservers, + "expire": @expire, + "renewal": @renewal, + "autoRenewal": @auto_renewal, + "renewalPrice": @renewal_price, + "transferStatus": @transfer_status, + "teamId": @team_id, + "dnsRecords": @dns_records.map { |it| it.to_map } + } + end + + private + + def validate_transfer_status(transfer_status) + valid_transfer_status = [ + Appwrite::Enums::DomainTransferStatusEnum::TRANSFERRABLE, + Appwrite::Enums::DomainTransferStatusEnum::NOT_TRANSFERRABLE, + Appwrite::Enums::DomainTransferStatusEnum::PENDING_OWNER, + Appwrite::Enums::DomainTransferStatusEnum::PENDING_ADMIN, + Appwrite::Enums::DomainTransferStatusEnum::PENDING_REGISTRY, + Appwrite::Enums::DomainTransferStatusEnum::COMPLETED, + Appwrite::Enums::DomainTransferStatusEnum::CANCELLED, + Appwrite::Enums::DomainTransferStatusEnum::SERVICE_UNAVAILABLE, + ] + + unless valid_transfer_status.include?(transfer_status) + raise ArgumentError, "Invalid " + transfer_status + ". Must be one of: " + valid_transfer_status.join(', ') + end + + transfer_status + end + end + end +end diff --git a/lib/appwrite/models/domain_price.rb b/lib/appwrite/models/domain_price.rb new file mode 100644 index 00000000..c67f7263 --- /dev/null +++ b/lib/appwrite/models/domain_price.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class DomainPrice + attr_reader :domain + attr_reader :tld + attr_reader :available + attr_reader :price + attr_reader :period_years + attr_reader :premium + attr_reader :renewal_price + attr_reader :renewal_period_years + + def initialize( + domain:, + tld:, + available:, + price:, + period_years:, + premium:, + renewal_price:, + renewal_period_years: + ) + @domain = domain + @tld = tld + @available = available + @price = price + @period_years = period_years + @premium = premium + @renewal_price = renewal_price + @renewal_period_years = renewal_period_years + end + + def self.from(map:) + map = { "domain" => "", "tld" => "", "available" => false, "periodYears" => 1, "premium" => false, "renewalPeriodYears" => 1 }.merge(map) + DomainPrice.new( + domain: map["domain"], + tld: map["tld"], + available: map["available"], + price: map["price"], + period_years: map["periodYears"], + premium: map["premium"], + renewal_price: map["renewalPrice"], + renewal_period_years: map["renewalPeriodYears"] + ) + end + + def to_map + { + "domain": @domain, + "tld": @tld, + "available": @available, + "price": @price, + "periodYears": @period_years, + "premium": @premium, + "renewalPrice": @renewal_price, + "renewalPeriodYears": @renewal_period_years + } + end + end + end +end diff --git a/lib/appwrite/models/domain_prices_list.rb b/lib/appwrite/models/domain_prices_list.rb new file mode 100644 index 00000000..601be0d9 --- /dev/null +++ b/lib/appwrite/models/domain_prices_list.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class DomainPricesList + attr_reader :total + attr_reader :prices + + def initialize( + total:, + prices: + ) + @total = total + @prices = prices + end + + def self.from(map:) + map = { "total" => 0 }.merge(map) + DomainPricesList.new( + total: map["total"], + prices: map["prices"].map { |it| DomainPrice.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "prices": @prices.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/domain_transfer_status.rb b/lib/appwrite/models/domain_transfer_status.rb new file mode 100644 index 00000000..911b13ae --- /dev/null +++ b/lib/appwrite/models/domain_transfer_status.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class DomainTransferStatus + attr_reader :status + attr_reader :reason + attr_reader :timestamp + + def initialize( + status:, + reason:, + timestamp: + ) + @status = validate_status(status) + @reason = reason + @timestamp = timestamp + end + + def self.from(map:) + map = { "status" => "pending_registry", "reason" => "", "timestamp" => "" }.merge(map) + DomainTransferStatus.new( + status: map["status"], + reason: map["reason"], + timestamp: map["timestamp"] + ) + end + + def to_map + { + "status": @status, + "reason": @reason, + "timestamp": @timestamp + } + end + + private + + def validate_status(status) + valid_status = [ + Appwrite::Enums::DomainTransferStatusEnum::TRANSFERRABLE, + Appwrite::Enums::DomainTransferStatusEnum::NOT_TRANSFERRABLE, + Appwrite::Enums::DomainTransferStatusEnum::PENDING_OWNER, + Appwrite::Enums::DomainTransferStatusEnum::PENDING_ADMIN, + Appwrite::Enums::DomainTransferStatusEnum::PENDING_REGISTRY, + Appwrite::Enums::DomainTransferStatusEnum::COMPLETED, + Appwrite::Enums::DomainTransferStatusEnum::CANCELLED, + Appwrite::Enums::DomainTransferStatusEnum::SERVICE_UNAVAILABLE, + ] + + unless valid_status.include?(status) + raise ArgumentError, "Invalid " + status + ". Must be one of: " + valid_status.join(', ') + end + + status + end + end + end +end diff --git a/lib/appwrite/models/domains_list.rb b/lib/appwrite/models/domains_list.rb new file mode 100644 index 00000000..f719d1b4 --- /dev/null +++ b/lib/appwrite/models/domains_list.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class DomainsList + attr_reader :total + attr_reader :domains + + def initialize( + total:, + domains: + ) + @total = total + @domains = domains + end + + def self.from(map:) + map = { "total" => 0 }.merge(map) + DomainsList.new( + total: map["total"], + domains: map["domains"].map { |it| Domain.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "domains": @domains.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/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..c683129f 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 }.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..fe7df739 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 }.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..5d129b0d 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" => "" }.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..864fa6ab 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" => "", "resourceId" => "", "resourceType" => "functions", "deploymentId" => "", "requestMethod" => "", "requestPath" => "", "responseStatusCode" => 0, "responseBody" => "", "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..e9075cad 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 }.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..59c6c5f7 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 }.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..eb493773 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" => "" }.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..d328c093 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 }.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..718d4a72 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" => [], "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..deb9a070 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 }.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 bd6e58cf..4261f302 100644 --- a/lib/appwrite/models/identity.rb +++ b/lib/appwrite/models/identity.rb @@ -13,6 +13,7 @@ class Identity attr_reader :provider_access_token attr_reader :provider_access_token_expiry attr_reader :provider_refresh_token + attr_reader :provider_id_token def initialize( id:, @@ -24,7 +25,8 @@ def initialize( provider_email:, provider_access_token:, provider_access_token_expiry:, - provider_refresh_token: + provider_refresh_token:, + provider_id_token: ) @id = id @created_at = created_at @@ -36,9 +38,11 @@ def initialize( @provider_access_token = provider_access_token @provider_access_token_expiry = provider_access_token_expiry @provider_refresh_token = provider_refresh_token + @provider_id_token = provider_id_token end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "userId" => "", "provider" => "", "providerUid" => "", "providerEmail" => "", "providerAccessToken" => "", "providerAccessTokenExpiry" => "", "providerRefreshToken" => "", "providerIdToken" => "" }.merge(map) Identity.new( id: map["$id"], created_at: map["$createdAt"], @@ -49,7 +53,8 @@ def self.from(map:) provider_email: map["providerEmail"], provider_access_token: map["providerAccessToken"], provider_access_token_expiry: map["providerAccessTokenExpiry"], - provider_refresh_token: map["providerRefreshToken"] + provider_refresh_token: map["providerRefreshToken"], + provider_id_token: map["providerIdToken"] ) end @@ -64,7 +69,8 @@ def to_map "providerEmail": @provider_email, "providerAccessToken": @provider_access_token, "providerAccessTokenExpiry": @provider_access_token_expiry, - "providerRefreshToken": @provider_refresh_token + "providerRefreshToken": @provider_refresh_token, + "providerIdToken": @provider_id_token } end end diff --git a/lib/appwrite/models/identity_list.rb b/lib/appwrite/models/identity_list.rb index bef444be..c68d7a12 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 }.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..7c52769b 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 }.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..6c317b4b 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" => "" }.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..4a95d96c 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 }.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..77040087 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" => "" }.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..3d493096 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 }.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..7501900c 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 }.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..c662e4f5 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 }.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/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..14a25303 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 }.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..d7102a8a 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" => "", "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..d6473392 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 }.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..ccca1204 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 }.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 bc7d9cba..ed1b5058 100644 --- a/lib/appwrite/models/o_auth2_apple.rb +++ b/lib/appwrite/models/o_auth2_apple.rb @@ -9,6 +9,8 @@ class OAuth2Apple attr_reader :key_id attr_reader :team_id attr_reader :p8_file + attr_reader :native_enabled + attr_reader :native_client_ids def initialize( id:, @@ -16,7 +18,9 @@ def initialize( service_id:, key_id:, team_id:, - p8_file: + p8_file:, + native_enabled:, + native_client_ids: ) @id = id @enabled = enabled @@ -24,16 +28,21 @@ def initialize( @key_id = key_id @team_id = team_id @p8_file = p8_file + @native_enabled = native_enabled + @native_client_ids = native_client_ids end def self.from(map:) + map = { "$id" => "", "enabled" => false, "serviceId" => "", "keyId" => "", "teamId" => "", "p8File" => "", "nativeEnabled" => false, "nativeClientIds" => [] }.merge(map) OAuth2Apple.new( id: map["$id"], enabled: map["enabled"], service_id: map["serviceId"], key_id: map["keyId"], team_id: map["teamId"], - p8_file: map["p8File"] + p8_file: map["p8File"], + native_enabled: map["nativeEnabled"], + native_client_ids: map["nativeClientIds"] ) end @@ -44,7 +53,9 @@ def to_map "serviceId": @service_id, "keyId": @key_id, "teamId": @team_id, - "p8File": @p8_file + "p8File": @p8_file, + "nativeEnabled": @native_enabled, + "nativeClientIds": @native_client_ids } end end diff --git a/lib/appwrite/models/o_auth2_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 aa261435..5611bd4c 100644 --- a/lib/appwrite/models/o_auth2_auth0.rb +++ b/lib/appwrite/models/o_auth2_auth0.rb @@ -7,6 +7,7 @@ class OAuth2Auth0 attr_reader :enabled attr_reader :client_id attr_reader :client_secret + attr_reader :prompt attr_reader :endpoint def initialize( @@ -14,21 +15,25 @@ def initialize( enabled:, client_id:, client_secret:, + prompt:, endpoint: ) @id = id @enabled = enabled @client_id = client_id @client_secret = client_secret + @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"], client_id: map["clientId"], client_secret: map["clientSecret"], + prompt: map["prompt"], endpoint: map["endpoint"] ) end @@ -39,9 +44,26 @@ def to_map "enabled": @enabled, "clientId": @client_id, "clientSecret": @client_secret, + "prompt": @prompt, "endpoint": @endpoint } end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2Auth0Prompt::NONE, + Appwrite::Enums::OAuth2Auth0Prompt::LOGIN, + Appwrite::Enums::OAuth2Auth0Prompt::CONSENT, + ] + + unless valid_prompt.include?(prompt) + raise ArgumentError, "Invalid " + prompt + ". Must be one of: " + valid_prompt.join(', ') + end + + prompt + end end end end 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 b24b44c8..9aa4babc 100644 --- a/lib/appwrite/models/o_auth2_discord.rb +++ b/lib/appwrite/models/o_auth2_discord.rb @@ -7,25 +7,30 @@ class OAuth2Discord attr_reader :enabled attr_reader :client_id attr_reader :client_secret + attr_reader :prompt def initialize( id:, enabled:, client_id:, - client_secret: + client_secret:, + prompt: ) @id = id @enabled = enabled @client_id = client_id @client_secret = client_secret + @prompt = 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"], client_id: map["clientId"], - client_secret: map["clientSecret"] + client_secret: map["clientSecret"], + prompt: map["prompt"] ) end @@ -34,9 +39,25 @@ def to_map "$id": @id, "enabled": @enabled, "clientId": @client_id, - "clientSecret": @client_secret + "clientSecret": @client_secret, + "prompt": @prompt } end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2DiscordPrompt::NONE, + Appwrite::Enums::OAuth2DiscordPrompt::CONSENT, + ] + + unless valid_prompt.include?(prompt) + raise ArgumentError, "Invalid " + prompt + ". Must be one of: " + valid_prompt.join(', ') + end + + prompt + end end end end 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 9f72146a..be421008 100644 --- a/lib/appwrite/models/o_auth2_github.rb +++ b/lib/appwrite/models/o_auth2_github.rb @@ -7,25 +7,30 @@ class OAuth2Github attr_reader :enabled attr_reader :client_id attr_reader :client_secret + attr_reader :prompt def initialize( id:, enabled:, client_id:, - client_secret: + client_secret:, + prompt: ) @id = id @enabled = enabled @client_id = client_id @client_secret = client_secret + @prompt = 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"], client_id: map["clientId"], - client_secret: map["clientSecret"] + client_secret: map["clientSecret"], + prompt: map["prompt"] ) end @@ -34,9 +39,24 @@ def to_map "$id": @id, "enabled": @enabled, "clientId": @client_id, - "clientSecret": @client_secret + "clientSecret": @client_secret, + "prompt": @prompt } end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2GithubPrompt::SELECT_ACCOUNT, + ] + + unless valid_prompt.include?(prompt) + raise ArgumentError, "Invalid " + prompt + ". Must be one of: " + valid_prompt.join(', ') + end + + prompt + end end end end 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 e220ee69..0b4929b3 100644 --- a/lib/appwrite/models/o_auth2_google.rb +++ b/lib/appwrite/models/o_auth2_google.rb @@ -8,28 +8,37 @@ class OAuth2Google attr_reader :client_id attr_reader :client_secret attr_reader :prompt + attr_reader :native_enabled + attr_reader :native_client_ids def initialize( id:, enabled:, client_id:, client_secret:, - prompt: + prompt:, + native_enabled:, + native_client_ids: ) @id = id @enabled = enabled @client_id = client_id @client_secret = client_secret @prompt = validate_prompt(prompt) + @native_enabled = native_enabled + @native_client_ids = native_client_ids end def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => ["consent"], "nativeEnabled" => false, "nativeClientIds" => [] }.merge(map) OAuth2Google.new( id: map["$id"], enabled: map["enabled"], client_id: map["clientId"], client_secret: map["clientSecret"], - prompt: map["prompt"] + prompt: map["prompt"], + native_enabled: map["nativeEnabled"], + native_client_ids: map["nativeClientIds"] ) end @@ -39,7 +48,9 @@ def to_map "enabled": @enabled, "clientId": @client_id, "clientSecret": @client_secret, - "prompt": @prompt + "prompt": @prompt, + "nativeEnabled": @native_enabled, + "nativeClientIds": @native_client_ids } end 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_kakao.rb b/lib/appwrite/models/o_auth2_kakao.rb new file mode 100644 index 00000000..aa9e6542 --- /dev/null +++ b/lib/appwrite/models/o_auth2_kakao.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class OAuth2Kakao + attr_reader :id + attr_reader :enabled + attr_reader :client_id + attr_reader :client_secret + attr_reader :prompt + + def initialize( + id:, + enabled:, + client_id:, + client_secret:, + prompt: + ) + @id = id + @enabled = enabled + @client_id = client_id + @client_secret = client_secret + @prompt = validate_prompt(prompt) + end + + def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "", "prompt" => [] }.merge(map) + OAuth2Kakao.new( + id: map["$id"], + enabled: map["enabled"], + client_id: map["clientId"], + client_secret: map["clientSecret"], + prompt: map["prompt"] + ) + end + + def to_map + { + "$id": @id, + "enabled": @enabled, + "clientId": @client_id, + "clientSecret": @client_secret, + "prompt": @prompt + } + end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2KakaoPrompt::NONE, + Appwrite::Enums::OAuth2KakaoPrompt::LOGIN, + Appwrite::Enums::OAuth2KakaoPrompt::CREATE, + Appwrite::Enums::OAuth2KakaoPrompt::SELECT_ACCOUNT, + ] + + unless valid_prompt.include?(prompt) + raise ArgumentError, "Invalid " + prompt + ". Must be one of: " + valid_prompt.join(', ') + end + + prompt + end + end + end +end 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 0173d394..9c7c88f3 100644 --- a/lib/appwrite/models/o_auth2_microsoft.rb +++ b/lib/appwrite/models/o_auth2_microsoft.rb @@ -7,6 +7,7 @@ class OAuth2Microsoft attr_reader :enabled attr_reader :application_id attr_reader :application_secret + attr_reader :prompt attr_reader :tenant def initialize( @@ -14,21 +15,25 @@ def initialize( enabled:, application_id:, application_secret:, + prompt:, tenant: ) @id = id @enabled = enabled @application_id = application_id @application_secret = application_secret + @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"], application_id: map["applicationId"], application_secret: map["applicationSecret"], + prompt: map["prompt"], tenant: map["tenant"] ) end @@ -39,9 +44,27 @@ def to_map "enabled": @enabled, "applicationId": @application_id, "applicationSecret": @application_secret, + "prompt": @prompt, "tenant": @tenant } end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2MicrosoftPrompt::NONE, + Appwrite::Enums::OAuth2MicrosoftPrompt::LOGIN, + Appwrite::Enums::OAuth2MicrosoftPrompt::CONSENT, + Appwrite::Enums::OAuth2MicrosoftPrompt::SELECT_ACCOUNT, + ] + + unless valid_prompt.include?(prompt) + raise ArgumentError, "Invalid " + prompt + ". Must be one of: " + valid_prompt.join(', ') + end + + prompt + end end end end 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 a4ea66fe..9b5d9a9e 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 61ef16ec..d1794083 100644 --- a/lib/appwrite/models/o_auth2_okta.rb +++ b/lib/appwrite/models/o_auth2_okta.rb @@ -7,6 +7,7 @@ class OAuth2Okta attr_reader :enabled attr_reader :client_id attr_reader :client_secret + attr_reader :prompt attr_reader :domain attr_reader :authorization_server_id @@ -15,6 +16,7 @@ def initialize( enabled:, client_id:, client_secret:, + prompt:, domain:, authorization_server_id: ) @@ -22,16 +24,19 @@ def initialize( @enabled = enabled @client_id = client_id @client_secret = client_secret + @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"], client_id: map["clientId"], client_secret: map["clientSecret"], + prompt: map["prompt"], domain: map["domain"], authorization_server_id: map["authorizationServerId"] ) @@ -43,10 +48,27 @@ def to_map "enabled": @enabled, "clientId": @client_id, "clientSecret": @client_secret, + "prompt": @prompt, "domain": @domain, "authorizationServerId": @authorization_server_id } end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2OktaPrompt::NONE, + Appwrite::Enums::OAuth2OktaPrompt::LOGIN, + Appwrite::Enums::OAuth2OktaPrompt::CONSENT, + ] + + unless valid_prompt.include?(prompt) + raise ArgumentError, "Invalid " + prompt + ". Must be one of: " + valid_prompt.join(', ') + end + + prompt + end end end end 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..e5e7c24a 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 }.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 22cdf2b6..6a2683f5 100644 --- a/lib/appwrite/models/o_auth2_salesforce.rb +++ b/lib/appwrite/models/o_auth2_salesforce.rb @@ -7,25 +7,30 @@ class OAuth2Salesforce attr_reader :enabled attr_reader :customer_key attr_reader :customer_secret + attr_reader :prompt def initialize( id:, enabled:, customer_key:, - customer_secret: + customer_secret:, + prompt: ) @id = id @enabled = enabled @customer_key = customer_key @customer_secret = customer_secret + @prompt = 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"], customer_key: map["customerKey"], - customer_secret: map["customerSecret"] + customer_secret: map["customerSecret"], + prompt: map["prompt"] ) end @@ -34,9 +39,25 @@ def to_map "$id": @id, "enabled": @enabled, "customerKey": @customer_key, - "customerSecret": @customer_secret + "customerSecret": @customer_secret, + "prompt": @prompt } end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2SalesforcePrompt::LOGIN, + Appwrite::Enums::OAuth2SalesforcePrompt::CONSENT, + ] + + unless valid_prompt.include?(prompt) + raise ArgumentError, "Invalid " + prompt + ". Must be one of: " + valid_prompt.join(', ') + end + + prompt + end end end end 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_tik_tok.rb b/lib/appwrite/models/o_auth2_tik_tok.rb new file mode 100644 index 00000000..65a4b630 --- /dev/null +++ b/lib/appwrite/models/o_auth2_tik_tok.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class OAuth2TikTok + attr_reader :id + attr_reader :enabled + attr_reader :client_id + attr_reader :client_secret + + def initialize( + id:, + enabled:, + client_id:, + client_secret: + ) + @id = id + @enabled = enabled + @client_id = client_id + @client_secret = client_secret + end + + def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) + OAuth2TikTok.new( + id: map["$id"], + enabled: map["enabled"], + client_id: map["clientId"], + client_secret: map["clientSecret"] + ) + end + + def to_map + { + "$id": @id, + "enabled": @enabled, + "clientId": @client_id, + "clientSecret": @client_secret + } + end + end + end +end diff --git a/lib/appwrite/models/o_auth2_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_webflow.rb b/lib/appwrite/models/o_auth2_webflow.rb new file mode 100644 index 00000000..a25ce1b4 --- /dev/null +++ b/lib/appwrite/models/o_auth2_webflow.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class OAuth2Webflow + attr_reader :id + attr_reader :enabled + attr_reader :client_id + attr_reader :client_secret + + def initialize( + id:, + enabled:, + client_id:, + client_secret: + ) + @id = id + @enabled = enabled + @client_id = client_id + @client_secret = client_secret + end + + def self.from(map:) + map = { "$id" => "", "enabled" => false, "clientId" => "", "clientSecret" => "" }.merge(map) + OAuth2Webflow.new( + id: map["$id"], + enabled: map["enabled"], + client_id: map["clientId"], + client_secret: map["clientSecret"] + ) + end + + def to_map + { + "$id": @id, + "enabled": @enabled, + "clientId": @client_id, + "clientSecret": @client_secret + } + end + end + end +end diff --git a/lib/appwrite/models/o_auth2_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 6b40cab0..fe610d15 100644 --- a/lib/appwrite/models/o_auth2_zoho.rb +++ b/lib/appwrite/models/o_auth2_zoho.rb @@ -7,25 +7,30 @@ class OAuth2Zoho attr_reader :enabled attr_reader :client_id attr_reader :client_secret + attr_reader :prompt def initialize( id:, enabled:, client_id:, - client_secret: + client_secret:, + prompt: ) @id = id @enabled = enabled @client_id = client_id @client_secret = client_secret + @prompt = 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"], client_id: map["clientId"], - client_secret: map["clientSecret"] + client_secret: map["clientSecret"], + prompt: map["prompt"] ) end @@ -34,9 +39,24 @@ def to_map "$id": @id, "enabled": @enabled, "clientId": @client_id, - "clientSecret": @client_secret + "clientSecret": @client_secret, + "prompt": @prompt } end + + private + + def validate_prompt(prompt) + valid_prompt = [ + Appwrite::Enums::OAuth2ZohoPrompt::CONSENT, + ] + + unless valid_prompt.include?(prompt) + raise ArgumentError, "Invalid " + prompt + ". Must be one of: " + valid_prompt.join(', ') + end + + prompt + end end end end 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..8c1e1614 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 }.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..43356732 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 }.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 new file mode 100644 index 00000000..ac104dc4 --- /dev/null +++ b/lib/appwrite/models/oauth2_introspection.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class Oauth2Introspection + attr_reader :active + attr_reader :token_use + attr_reader :token_type + attr_reader :scope + attr_reader :client_id + attr_reader :sub + attr_reader :aud + attr_reader :iss + attr_reader :exp + attr_reader :iat + attr_reader :jti + attr_reader :authorization_details + + def initialize( + active:, + token_use:, + token_type:, + scope:, + client_id:, + sub:, + aud:, + iss:, + exp:, + iat:, + jti:, + authorization_details: + ) + @active = active + @token_use = token_use + @token_type = token_type + @scope = scope + @client_id = client_id + @sub = sub + @aud = aud + @iss = iss + @exp = exp + @iat = iat + @jti = jti + @authorization_details = authorization_details + end + + def self.from(map:) + map = { "active" => false }.merge(map) + Oauth2Introspection.new( + active: map["active"], + token_use: map["token_use"], + token_type: map["token_type"], + scope: map["scope"], + client_id: map["client_id"], + sub: map["sub"], + aud: map["aud"], + iss: map["iss"], + exp: map["exp"], + iat: map["iat"], + jti: map["jti"], + authorization_details: map["authorization_details"] + ) + end + + def to_map + { + "active": @active, + "token_use": @token_use, + "token_type": @token_type, + "scope": @scope, + "client_id": @client_id, + "sub": @sub, + "aud": @aud, + "iss": @iss, + "exp": @exp, + "iat": @iat, + "jti": @jti, + "authorization_details": @authorization_details + } + end + end + end +end diff --git a/lib/appwrite/models/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..6e4ec69a 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 }.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..1566fc46 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 }.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/dev_key.rb b/lib/appwrite/models/passkey.rb similarity index 61% rename from lib/appwrite/models/dev_key.rb rename to lib/appwrite/models/passkey.rb index 4389e82a..8cea8129 100644 --- a/lib/appwrite/models/dev_key.rb +++ b/lib/appwrite/models/passkey.rb @@ -2,46 +2,35 @@ module Appwrite module Models - class DevKey + class Passkey 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: + accessed_at: ) @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( + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "accessedAt" => "" }.merge(map) + Passkey.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"] + accessed_at: map["accessedAt"] ) end @@ -51,10 +40,7 @@ def to_map "$createdAt": @created_at, "$updatedAt": @updated_at, "name": @name, - "expire": @expire, - "secret": @secret, - "accessedAt": @accessed_at, - "sdks": @sdks + "accessedAt": @accessed_at } end end diff --git a/lib/appwrite/models/passkey_challenge.rb b/lib/appwrite/models/passkey_challenge.rb new file mode 100644 index 00000000..22f1774c --- /dev/null +++ b/lib/appwrite/models/passkey_challenge.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class PasskeyChallenge + attr_reader :id + attr_reader :created_at + attr_reader :passkey_id + attr_reader :expire + attr_reader :public_key + + def initialize( + id:, + created_at:, + passkey_id:, + expire:, + public_key: + ) + @id = id + @created_at = created_at + @passkey_id = passkey_id + @expire = expire + @public_key = public_key + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "passkeyId" => "", "expire" => "", "publicKey" => {} }.merge(map) + PasskeyChallenge.new( + id: map["$id"], + created_at: map["$createdAt"], + passkey_id: map["passkeyId"], + expire: map["expire"], + public_key: map["publicKey"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "passkeyId": @passkey_id, + "expire": @expire, + "publicKey": @public_key + } + end + end + end +end diff --git a/lib/appwrite/models/passkey_list.rb b/lib/appwrite/models/passkey_list.rb new file mode 100644 index 00000000..75e7172f --- /dev/null +++ b/lib/appwrite/models/passkey_list.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class PasskeyList + attr_reader :total + attr_reader :passkeys + + def initialize( + total:, + passkeys: + ) + @total = total + @passkeys = passkeys + end + + def self.from(map:) + map = { "total" => 0 }.merge(map) + PasskeyList.new( + total: map["total"], + passkeys: map["passkeys"].map { |it| Passkey.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "passkeys": @passkeys.map { |it| it.to_map } + } + end + end + end +end 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..d02cddec 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 }.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 64b05d7d..3559270e 100644 --- a/lib/appwrite/models/platform_android.rb +++ b/lib/appwrite/models/platform_android.rb @@ -9,6 +9,7 @@ class PlatformAndroid attr_reader :name attr_reader :type attr_reader :application_id + attr_reader :fingerprints def initialize( id:, @@ -16,7 +17,8 @@ def initialize( updated_at:, name:, type:, - application_id: + application_id:, + fingerprints: ) @id = id @created_at = created_at @@ -24,16 +26,19 @@ def initialize( @name = name @type = validate_type(type) @application_id = application_id + @fingerprints = fingerprints end def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "applicationId" => "", "fingerprints" => [] }.merge(map) PlatformAndroid.new( id: map["$id"], created_at: map["$createdAt"], updated_at: map["$updatedAt"], name: map["name"], type: map["type"], - application_id: map["applicationId"] + application_id: map["applicationId"], + fingerprints: map["fingerprints"] ) end @@ -44,7 +49,8 @@ def to_map "$updatedAt": @updated_at, "name": @name, "type": @type, - "applicationId": @application_id + "applicationId": @application_id, + "fingerprints": @fingerprints } end diff --git a/lib/appwrite/models/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..8a858717 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 }.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..cd94f064 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 }.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 new file mode 100644 index 00000000..62bced03 --- /dev/null +++ b/lib/appwrite/models/policy_passkey.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class PolicyPasskey + attr_reader :id + attr_reader :rp_id + attr_reader :origins + + def initialize( + id:, + rp_id:, + origins: + ) + @id = id + @rp_id = rp_id + @origins = origins + end + + def self.from(map:) + map = { "$id" => "", "rpId" => "", "origins" => [] }.merge(map) + PolicyPasskey.new( + id: map["$id"], + rp_id: map["rpId"], + origins: map["origins"] + ) + end + + def to_map + { + "$id": @id, + "rpId": @rp_id, + "origins": @origins + } + end + end + end +end 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_pwned.rb b/lib/appwrite/models/policy_password_pwned.rb new file mode 100644 index 00000000..e2365e96 --- /dev/null +++ b/lib/appwrite/models/policy_password_pwned.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class PolicyPasswordPwned + attr_reader :id + attr_reader :enabled + attr_reader :sessions + attr_reader :users + + def initialize( + id:, + enabled:, + sessions:, + users: + ) + @id = id + @enabled = enabled + @sessions = sessions + @users = users + end + + def self.from(map:) + map = { "$id" => "", "enabled" => true, "sessions" => false, "users" => false }.merge(map) + PolicyPasswordPwned.new( + id: map["$id"], + enabled: map["enabled"], + sessions: map["sessions"], + users: map["users"] + ) + end + + def to_map + { + "$id": @id, + "enabled": @enabled, + "sessions": @sessions, + "users": @users + } + end + end + end +end diff --git a/lib/appwrite/models/policy_password_rotation.rb b/lib/appwrite/models/policy_password_rotation.rb new file mode 100644 index 00000000..c451d766 --- /dev/null +++ b/lib/appwrite/models/policy_password_rotation.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class PolicyPasswordRotation + attr_reader :id + attr_reader :enabled + attr_reader :max_age + + def initialize( + id:, + enabled:, + max_age: + ) + @id = id + @enabled = enabled + @max_age = max_age + end + + def self.from(map:) + map = { "$id" => "", "enabled" => false, "maxAge" => 31536000 }.merge(map) + PolicyPasswordRotation.new( + id: map["$id"], + enabled: map["enabled"], + max_age: map["maxAge"] + ) + end + + def to_map + { + "$id": @id, + "enabled": @enabled, + "maxAge": @max_age + } + end + end + end +end diff --git a/lib/appwrite/models/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..e618856e 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" => "", "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..590f1109 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 }.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 3e508814..309e169a 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 @@ -32,6 +31,8 @@ class Project attr_reader :console_accessed_at attr_reader :waf_enabled attr_reader :billing_limits + attr_reader :first_accessed_at + attr_reader :mcp_accessed_at attr_reader :o_auth2_server_enabled attr_reader :o_auth2_server_authorization_url attr_reader :o_auth2_server_scopes @@ -57,7 +58,6 @@ def initialize( name:, team_id:, region:, - dev_keys:, smtp_enabled:, smtp_sender_name:, smtp_sender_email:, @@ -80,22 +80,24 @@ def initialize( console_accessed_at:, waf_enabled:, 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_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 @@ -104,7 +106,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 @@ -127,6 +128,8 @@ def initialize( @console_accessed_at = console_accessed_at @waf_enabled = waf_enabled @billing_limits = billing_limits + @first_accessed_at = first_accessed_at + @mcp_accessed_at = mcp_accessed_at @o_auth2_server_enabled = o_auth2_server_enabled @o_auth2_server_authorization_url = o_auth2_server_authorization_url @o_auth2_server_scopes = o_auth2_server_scopes @@ -147,6 +150,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" => {}, "consoleAccessedAt" => "" }.merge(map) Project.new( id: map["$id"], created_at: map["$createdAt"], @@ -154,7 +158,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"], @@ -177,6 +180,8 @@ def self.from(map:) console_accessed_at: map["consoleAccessedAt"], waf_enabled: map["wafEnabled"], billing_limits: map["billingLimits"].nil? ? nil : BillingLimits.from(map: map["billingLimits"]), + first_accessed_at: map["firstAccessedAt"], + mcp_accessed_at: map["mcpAccessedAt"], o_auth2_server_enabled: map["oAuth2ServerEnabled"], o_auth2_server_authorization_url: map["oAuth2ServerAuthorizationUrl"], o_auth2_server_scopes: map["oAuth2ServerScopes"], @@ -205,7 +210,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, @@ -228,6 +232,8 @@ def to_map "consoleAccessedAt": @console_accessed_at, "wafEnabled": @waf_enabled, "billingLimits": @billing_limits&.to_map, + "firstAccessedAt": @first_accessed_at, + "mcpAccessedAt": @mcp_accessed_at, "oAuth2ServerEnabled": @o_auth2_server_enabled, "oAuth2ServerAuthorizationUrl": @o_auth2_server_authorization_url, "oAuth2ServerScopes": @o_auth2_server_scopes, diff --git a/lib/appwrite/models/project_auth_method.rb b/lib/appwrite/models/project_auth_method.rb index 8aa64812..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"] @@ -39,6 +40,7 @@ def validate_id(id) Appwrite::Enums::ProjectAuthMethodId::INVITES, Appwrite::Enums::ProjectAuthMethodId::JWT, Appwrite::Enums::ProjectAuthMethodId::PHONE, + Appwrite::Enums::ProjectAuthMethodId::PASSKEY, ] unless valid_id.include?(id) diff --git a/lib/appwrite/models/project_list.rb b/lib/appwrite/models/project_list.rb index 552309a5..cbc8e88b 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 }.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 6f426843..5bfe068c 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..5b7cf217 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 }.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 adb1cd58..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"], @@ -99,6 +100,7 @@ def validate_deployment_resource_type(deployment_resource_type) valid_deployment_resource_type = [ Appwrite::Enums::ProxyRuleDeploymentResourceType::FUNCTION, Appwrite::Enums::ProxyRuleDeploymentResourceType::SITE, + Appwrite::Enums::ProxyRuleDeploymentResourceType::DEDICATEDDATABASE, ] unless valid_deployment_resource_type.include?(deployment_resource_type) diff --git a/lib/appwrite/models/proxy_rule_list.rb b/lib/appwrite/models/proxy_rule_list.rb index 24f99239..73b7af00 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 }.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..96f1d795 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" => [] }.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..ff5c023d 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 }.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..220ca1eb 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 }.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..a95355b5 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" => "" }.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..0c88227f 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 }.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..28d1737e 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" => "" }.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..eb0e2bf8 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 }.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..a01225cb 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 }.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..ac8b02e4 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" => [], "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..aa8bb1e0 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 }.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..10b8478c 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 }.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..308a1649 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 }.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..ed6e8dde 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" => "", "databaseId" => "", "name" => "", "enabled" => true, "rowSecurity" => false, "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..57993104 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 }.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..03c67535 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 }.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..ca4e9ca1 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 }.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 new file mode 100644 index 00000000..31ef131b --- /dev/null +++ b/lib/appwrite/models/token_secret.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class TokenSecret + attr_reader :id + attr_reader :created_at + attr_reader :user_id + attr_reader :secret + attr_reader :expire + attr_reader :phrase + + def initialize( + id:, + created_at:, + user_id:, + secret:, + expire:, + phrase: + ) + @id = id + @created_at = created_at + @user_id = user_id + @secret = secret + @expire = expire + @phrase = phrase + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "userId" => "", "secret" => "", "expire" => "", "phrase" => "" }.merge(map) + TokenSecret.new( + id: map["$id"], + created_at: map["$createdAt"], + user_id: map["userId"], + secret: map["secret"], + expire: map["expire"], + phrase: map["phrase"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "userId": @user_id, + "secret": @secret, + "expire": @expire, + "phrase": @phrase + } + end + end + end +end diff --git a/lib/appwrite/models/topic.rb b/lib/appwrite/models/topic.rb index 4034f4b3..9f7c6a6c 100644 --- a/lib/appwrite/models/topic.rb +++ b/lib/appwrite/models/topic.rb @@ -11,6 +11,8 @@ class Topic attr_reader :sms_total attr_reader :push_total attr_reader :subscribe + attr_reader :qos + attr_reader :expiry def initialize( id:, @@ -20,7 +22,9 @@ def initialize( email_total:, sms_total:, push_total:, - subscribe: + subscribe:, + qos:, + expiry: ) @id = id @created_at = created_at @@ -30,9 +34,12 @@ def initialize( @sms_total = sms_total @push_total = push_total @subscribe = subscribe + @qos = qos + @expiry = expiry 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"], @@ -41,7 +48,9 @@ def self.from(map:) email_total: map["emailTotal"], sms_total: map["smsTotal"], push_total: map["pushTotal"], - subscribe: map["subscribe"] + subscribe: map["subscribe"], + qos: map["qos"], + expiry: map["expiry"] ) end @@ -54,7 +63,9 @@ def to_map "emailTotal": @email_total, "smsTotal": @sms_total, "pushTotal": @push_total, - "subscribe": @subscribe + "subscribe": @subscribe, + "qos": @qos, + "expiry": @expiry } end end diff --git a/lib/appwrite/models/topic_list.rb b/lib/appwrite/models/topic_list.rb index e1b8c6d0..060ccda2 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 }.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..383d1ab1 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 }.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 aa133c24..987e37f9 100644 --- a/lib/appwrite/models/user.rb +++ b/lib/appwrite/models/user.rb @@ -22,6 +22,7 @@ class User attr_reader :email_is_disposable attr_reader :email_is_corporate attr_reader :email_is_canonical + attr_reader :password_pwned attr_reader :phone_verification attr_reader :mfa attr_reader :prefs @@ -50,6 +51,7 @@ def initialize( email_is_disposable:, email_is_corporate:, email_is_canonical:, + password_pwned:, phone_verification:, mfa:, prefs:, @@ -77,6 +79,7 @@ def initialize( @email_is_disposable = email_is_disposable @email_is_corporate = email_is_corporate @email_is_canonical = email_is_canonical + @password_pwned = password_pwned @phone_verification = phone_verification @mfa = mfa @prefs = prefs @@ -87,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, "accessedAt" => "" }.merge(map) User.new( id: map["$id"], created_at: map["$createdAt"], @@ -107,6 +111,7 @@ def self.from(map:) email_is_disposable: map["emailIsDisposable"], email_is_corporate: map["emailIsCorporate"], email_is_canonical: map["emailIsCanonical"], + password_pwned: map["passwordPwned"], phone_verification: map["phoneVerification"], mfa: map["mfa"], prefs: Preferences.from(map: map["prefs"]), @@ -138,6 +143,7 @@ def to_map "emailIsDisposable": @email_is_disposable, "emailIsCorporate": @email_is_corporate, "emailIsCanonical": @email_is_canonical, + "passwordPwned": @password_pwned, "phoneVerification": @phone_verification, "mfa": @mfa, "prefs": @prefs.to_map, diff --git a/lib/appwrite/models/user_list.rb b/lib/appwrite/models/user_list.rb index 79c4c6d3..5c663a4a 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 }.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..15907752 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 }.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..ada7794f 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" => "", "databaseId" => "", "name" => "", "enabled" => true, "documentSecurity" => false, "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..b1d507a2 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 }.merge(map) VectorsdbCollectionList.new( total: map["total"], collections: map["collections"].map { |it| VectorsdbCollection.from(map: it) } diff --git a/lib/appwrite/models/waf_rule_bypass.rb b/lib/appwrite/models/waf_rule_bypass.rb new file mode 100644 index 00000000..c7806d55 --- /dev/null +++ b/lib/appwrite/models/waf_rule_bypass.rb @@ -0,0 +1,111 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class WafRuleBypass + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :description + attr_reader :team_id + attr_reader :project_id + attr_reader :resource_type + attr_reader :resource_id + attr_reader :action + attr_reader :priority + attr_reader :enabled + attr_reader :conditions + attr_reader :config + + def initialize( + id:, + created_at:, + updated_at:, + name:, + description:, + team_id:, + project_id:, + resource_type:, + resource_id:, + action:, + priority:, + enabled:, + conditions:, + config: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @description = description + @team_id = team_id + @project_id = project_id + @resource_type = resource_type + @resource_id = resource_id + @action = validate_action(action) + @priority = priority + @enabled = enabled + @conditions = conditions + @config = config + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "description" => "", "teamId" => "", "projectId" => "", "resourceType" => "api", "resourceId" => "", "priority" => 0, "enabled" => true, "conditions" => [], "config" => {} }.merge(map) + WafRuleBypass.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + description: map["description"], + team_id: map["teamId"], + project_id: map["projectId"], + resource_type: map["resourceType"], + resource_id: map["resourceId"], + action: map["action"], + priority: map["priority"], + enabled: map["enabled"], + conditions: map["conditions"], + config: map["config"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "description": @description, + "teamId": @team_id, + "projectId": @project_id, + "resourceType": @resource_type, + "resourceId": @resource_id, + "action": @action, + "priority": @priority, + "enabled": @enabled, + "conditions": @conditions, + "config": @config + } + end + + private + + def validate_action(action) + valid_action = [ + Appwrite::Enums::WafRuleAction::BYPASS, + Appwrite::Enums::WafRuleAction::DENY, + Appwrite::Enums::WafRuleAction::CHALLENGE, + Appwrite::Enums::WafRuleAction::RATELIMIT, + Appwrite::Enums::WafRuleAction::REDIRECT, + ] + + unless valid_action.include?(action) + raise ArgumentError, "Invalid " + action + ". Must be one of: " + valid_action.join(', ') + end + + action + end + end + end +end diff --git a/lib/appwrite/models/waf_rule_challenge.rb b/lib/appwrite/models/waf_rule_challenge.rb new file mode 100644 index 00000000..1fc48b29 --- /dev/null +++ b/lib/appwrite/models/waf_rule_challenge.rb @@ -0,0 +1,126 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class WafRuleChallenge + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :description + attr_reader :team_id + attr_reader :project_id + attr_reader :resource_type + attr_reader :resource_id + attr_reader :action + attr_reader :priority + attr_reader :enabled + attr_reader :conditions + attr_reader :config + attr_reader :challenge_type + attr_reader :difficulty + attr_reader :ttl + + def initialize( + id:, + created_at:, + updated_at:, + name:, + description:, + team_id:, + project_id:, + resource_type:, + resource_id:, + action:, + priority:, + enabled:, + conditions:, + config:, + challenge_type:, + difficulty:, + ttl: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @description = description + @team_id = team_id + @project_id = project_id + @resource_type = resource_type + @resource_id = resource_id + @action = validate_action(action) + @priority = priority + @enabled = enabled + @conditions = conditions + @config = config + @challenge_type = challenge_type + @difficulty = difficulty + @ttl = ttl + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "description" => "", "teamId" => "", "projectId" => "", "resourceType" => "api", "resourceId" => "", "priority" => 0, "enabled" => true, "conditions" => [], "config" => {}, "challengeType" => "compute", "difficulty" => 3, "ttl" => 1800 }.merge(map) + WafRuleChallenge.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + description: map["description"], + team_id: map["teamId"], + project_id: map["projectId"], + resource_type: map["resourceType"], + resource_id: map["resourceId"], + action: map["action"], + priority: map["priority"], + enabled: map["enabled"], + conditions: map["conditions"], + config: map["config"], + challenge_type: map["challengeType"], + difficulty: map["difficulty"], + ttl: map["ttl"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "description": @description, + "teamId": @team_id, + "projectId": @project_id, + "resourceType": @resource_type, + "resourceId": @resource_id, + "action": @action, + "priority": @priority, + "enabled": @enabled, + "conditions": @conditions, + "config": @config, + "challengeType": @challenge_type, + "difficulty": @difficulty, + "ttl": @ttl + } + end + + private + + def validate_action(action) + valid_action = [ + Appwrite::Enums::WafRuleAction::BYPASS, + Appwrite::Enums::WafRuleAction::DENY, + Appwrite::Enums::WafRuleAction::CHALLENGE, + Appwrite::Enums::WafRuleAction::RATELIMIT, + Appwrite::Enums::WafRuleAction::REDIRECT, + ] + + unless valid_action.include?(action) + raise ArgumentError, "Invalid " + action + ". Must be one of: " + valid_action.join(', ') + end + + action + end + end + end +end diff --git a/lib/appwrite/models/waf_rule_deny.rb b/lib/appwrite/models/waf_rule_deny.rb new file mode 100644 index 00000000..4522a155 --- /dev/null +++ b/lib/appwrite/models/waf_rule_deny.rb @@ -0,0 +1,111 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class WafRuleDeny + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :description + attr_reader :team_id + attr_reader :project_id + attr_reader :resource_type + attr_reader :resource_id + attr_reader :action + attr_reader :priority + attr_reader :enabled + attr_reader :conditions + attr_reader :config + + def initialize( + id:, + created_at:, + updated_at:, + name:, + description:, + team_id:, + project_id:, + resource_type:, + resource_id:, + action:, + priority:, + enabled:, + conditions:, + config: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @description = description + @team_id = team_id + @project_id = project_id + @resource_type = resource_type + @resource_id = resource_id + @action = validate_action(action) + @priority = priority + @enabled = enabled + @conditions = conditions + @config = config + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "description" => "", "teamId" => "", "projectId" => "", "resourceType" => "api", "resourceId" => "", "priority" => 0, "enabled" => true, "conditions" => [], "config" => {} }.merge(map) + WafRuleDeny.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + description: map["description"], + team_id: map["teamId"], + project_id: map["projectId"], + resource_type: map["resourceType"], + resource_id: map["resourceId"], + action: map["action"], + priority: map["priority"], + enabled: map["enabled"], + conditions: map["conditions"], + config: map["config"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "description": @description, + "teamId": @team_id, + "projectId": @project_id, + "resourceType": @resource_type, + "resourceId": @resource_id, + "action": @action, + "priority": @priority, + "enabled": @enabled, + "conditions": @conditions, + "config": @config + } + end + + private + + def validate_action(action) + valid_action = [ + Appwrite::Enums::WafRuleAction::BYPASS, + Appwrite::Enums::WafRuleAction::DENY, + Appwrite::Enums::WafRuleAction::CHALLENGE, + Appwrite::Enums::WafRuleAction::RATELIMIT, + Appwrite::Enums::WafRuleAction::REDIRECT, + ] + + unless valid_action.include?(action) + raise ArgumentError, "Invalid " + action + ". Must be one of: " + valid_action.join(', ') + end + + action + end + end + end +end diff --git a/lib/appwrite/models/log_list.rb b/lib/appwrite/models/waf_rule_list.rb similarity index 62% rename from lib/appwrite/models/log_list.rb rename to lib/appwrite/models/waf_rule_list.rb index cdad965e..19cc034a 100644 --- a/lib/appwrite/models/log_list.rb +++ b/lib/appwrite/models/waf_rule_list.rb @@ -2,29 +2,30 @@ module Appwrite module Models - class LogList + class WafRuleList attr_reader :total - attr_reader :logs + attr_reader :rules def initialize( total:, - logs: + rules: ) @total = total - @logs = logs + @rules = rules end def self.from(map:) - LogList.new( + map = { "total" => 0 }.merge(map) + WafRuleList.new( total: map["total"], - logs: map["logs"].map { |it| Log.from(map: it) } + rules: map["rules"] ) end def to_map { "total": @total, - "logs": @logs.map { |it| it.to_map } + "rules": @rules } end end diff --git a/lib/appwrite/models/waf_rule_rate_limit.rb b/lib/appwrite/models/waf_rule_rate_limit.rb new file mode 100644 index 00000000..1b6288d2 --- /dev/null +++ b/lib/appwrite/models/waf_rule_rate_limit.rb @@ -0,0 +1,136 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class WafRuleRateLimit + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :description + attr_reader :team_id + attr_reader :project_id + attr_reader :resource_type + attr_reader :resource_id + attr_reader :action + attr_reader :priority + attr_reader :enabled + attr_reader :conditions + attr_reader :config + attr_reader :limit + attr_reader :interval + attr_reader :key + attr_reader :strategy + attr_reader :max_bucket_size + + def initialize( + id:, + created_at:, + updated_at:, + name:, + description:, + team_id:, + project_id:, + resource_type:, + resource_id:, + action:, + priority:, + enabled:, + conditions:, + config:, + limit:, + interval:, + key:, + strategy:, + max_bucket_size: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @description = description + @team_id = team_id + @project_id = project_id + @resource_type = resource_type + @resource_id = resource_id + @action = validate_action(action) + @priority = priority + @enabled = enabled + @conditions = conditions + @config = config + @limit = limit + @interval = interval + @key = key + @strategy = strategy + @max_bucket_size = max_bucket_size + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "description" => "", "teamId" => "", "projectId" => "", "resourceType" => "api", "resourceId" => "", "priority" => 0, "enabled" => true, "conditions" => [], "config" => {}, "limit" => 100, "interval" => 3600, "key" => "ip", "strategy" => "fixedWindow", "maxBucketSize" => 0 }.merge(map) + WafRuleRateLimit.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + description: map["description"], + team_id: map["teamId"], + project_id: map["projectId"], + resource_type: map["resourceType"], + resource_id: map["resourceId"], + action: map["action"], + priority: map["priority"], + enabled: map["enabled"], + conditions: map["conditions"], + config: map["config"], + limit: map["limit"], + interval: map["interval"], + key: map["key"], + strategy: map["strategy"], + max_bucket_size: map["maxBucketSize"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "description": @description, + "teamId": @team_id, + "projectId": @project_id, + "resourceType": @resource_type, + "resourceId": @resource_id, + "action": @action, + "priority": @priority, + "enabled": @enabled, + "conditions": @conditions, + "config": @config, + "limit": @limit, + "interval": @interval, + "key": @key, + "strategy": @strategy, + "maxBucketSize": @max_bucket_size + } + end + + private + + def validate_action(action) + valid_action = [ + Appwrite::Enums::WafRuleAction::BYPASS, + Appwrite::Enums::WafRuleAction::DENY, + Appwrite::Enums::WafRuleAction::CHALLENGE, + Appwrite::Enums::WafRuleAction::RATELIMIT, + Appwrite::Enums::WafRuleAction::REDIRECT, + ] + + unless valid_action.include?(action) + raise ArgumentError, "Invalid " + action + ". Must be one of: " + valid_action.join(', ') + end + + action + end + end + end +end diff --git a/lib/appwrite/models/waf_rule_redirect.rb b/lib/appwrite/models/waf_rule_redirect.rb new file mode 100644 index 00000000..a3b5a842 --- /dev/null +++ b/lib/appwrite/models/waf_rule_redirect.rb @@ -0,0 +1,121 @@ +# frozen_string_literal: true + +module Appwrite + module Models + class WafRuleRedirect + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :description + attr_reader :team_id + attr_reader :project_id + attr_reader :resource_type + attr_reader :resource_id + attr_reader :action + attr_reader :priority + attr_reader :enabled + attr_reader :conditions + attr_reader :config + attr_reader :location + attr_reader :status_code + + def initialize( + id:, + created_at:, + updated_at:, + name:, + description:, + team_id:, + project_id:, + resource_type:, + resource_id:, + action:, + priority:, + enabled:, + conditions:, + config:, + location:, + status_code: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @description = description + @team_id = team_id + @project_id = project_id + @resource_type = resource_type + @resource_id = resource_id + @action = validate_action(action) + @priority = priority + @enabled = enabled + @conditions = conditions + @config = config + @location = location + @status_code = status_code + end + + def self.from(map:) + map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "name" => "", "description" => "", "teamId" => "", "projectId" => "", "resourceType" => "api", "resourceId" => "", "priority" => 0, "enabled" => true, "conditions" => [], "config" => {}, "location" => "/", "statusCode" => 302 }.merge(map) + WafRuleRedirect.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + description: map["description"], + team_id: map["teamId"], + project_id: map["projectId"], + resource_type: map["resourceType"], + resource_id: map["resourceId"], + action: map["action"], + priority: map["priority"], + enabled: map["enabled"], + conditions: map["conditions"], + config: map["config"], + location: map["location"], + status_code: map["statusCode"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "description": @description, + "teamId": @team_id, + "projectId": @project_id, + "resourceType": @resource_type, + "resourceId": @resource_id, + "action": @action, + "priority": @priority, + "enabled": @enabled, + "conditions": @conditions, + "config": @config, + "location": @location, + "statusCode": @status_code + } + end + + private + + def validate_action(action) + valid_action = [ + Appwrite::Enums::WafRuleAction::BYPASS, + Appwrite::Enums::WafRuleAction::DENY, + Appwrite::Enums::WafRuleAction::CHALLENGE, + Appwrite::Enums::WafRuleAction::RATELIMIT, + Appwrite::Enums::WafRuleAction::REDIRECT, + ] + + unless valid_action.include?(action) + raise ArgumentError, "Invalid " + action + ". Must be one of: " + valid_action.join(', ') + end + + action + end + end + end +end diff --git a/lib/appwrite/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..450ced2f 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 }.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 4d8bceb9..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,154 @@ def update_mfa_recovery_codes() def update_name( name: ) + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + api_path = '/account/name' + api_params = { + name: name, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::User + ) + end + + # Get the list of verified passkeys registered by the currently logged in + # user. + # + # @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 and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [PasskeyList] + def list_passkeys( + queries: nil, + total: nil + ) + api_path = '/account/passkeys' + + 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::PasskeyList + ) + end + + # Start registering a passkey for the currently logged in user. The session + # must have signed in or completed an MFA challenge within the last 10 + # minutes. Pass the returned `publicKey` options to + # `navigator.credentials.create()`, then complete the registration with + # [Update passkey + # verification](/docs/references/cloud/client-web/account#updatePasskeyVerification). + # The passkey stays pending until verified, and the challenge expires after 5 + # minutes. + # + # @param [String] passkey_id Passkey 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 Passkey name, shown when listing passkeys. Max length: 128 chars. + # + # @return [PasskeyChallenge] + def create_passkey( + passkey_id: nil, + name: nil + ) + api_path = '/account/passkeys' + + api_params = { + passkeyId: passkey_id, + name: name, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::PasskeyChallenge + ) + end + + # Get a verified passkey of the currently logged in user by its unique ID. + # + # @param [String] passkey_id Passkey ID. + # + # @return [Passkey] + def get_passkey( + passkey_id: + ) + if passkey_id.nil? || passkey_id == '' + raise Appwrite::Exception.new('Missing required parameter: "passkeyId"') + end + + api_path = '/account/passkeys/{passkeyId}' + .gsub('{passkeyId}', passkey_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::Passkey + ) + end + + # Rename a passkey of the currently logged in user. + # + # @param [String] passkey_id Passkey ID. + # @param [String] name Passkey name. Max length: 128 chars. + # + # @return [Passkey] + def update_passkey( + passkey_id:, + name: + ) + if passkey_id.nil? || passkey_id == '' + raise Appwrite::Exception.new('Missing required parameter: "passkeyId"') + end + if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/account/passkeys/{passkeyId}' + .gsub('{passkeyId}', passkey_id) + api_params = { name: name, } @@ -793,7 +905,85 @@ def update_name( path: api_path, headers: api_headers, params: api_params, - response_type: Models::User + response_type: Models::Passkey + ) + end + + # Delete a passkey from the currently logged in user. The passkey can no + # longer be used to sign in, although it may remain stored on the user's + # device. The session must have signed in or completed an MFA challenge + # within the last 10 minutes. + # + # @param [String] passkey_id Passkey ID. + # + # @return [] + def delete_passkey( + passkey_id: + ) + if passkey_id.nil? || passkey_id == '' + raise Appwrite::Exception.new('Missing required parameter: "passkeyId"') + end + + api_path = '/account/passkeys/{passkeyId}' + .gsub('{passkeyId}', passkey_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + end + + # Complete a passkey registration started with [Create + # passkey](/docs/references/cloud/client-web/account#createPasskey). Pass the + # JSON form of the credential returned by `navigator.credentials.create()`, + # for example `credential.toJSON()`. Each registration can be verified once; + # a failed attempt requires starting it again. + # + # @param [String] passkey_id Passkey ID. + # @param [Hash] credential Registration credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + # + # @return [Passkey] + def update_passkey_verification( + passkey_id:, + credential: + ) + if passkey_id.nil? || passkey_id == '' + raise Appwrite::Exception.new('Missing required parameter: "passkeyId"') + end + + if credential.nil? + raise Appwrite::Exception.new('Missing required parameter: "credential"') + end + + api_path = '/account/passkeys/{passkeyId}/verification' + .gsub('{passkeyId}', passkey_id) + + api_params = { + credential: credential, + } + + 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::Passkey ) end @@ -809,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, @@ -849,8 +1039,6 @@ def update_phone( phone:, password: ) - api_path = '/account/phone' - if phone.nil? raise Appwrite::Exception.new('Missing required parameter: "phone"') end @@ -859,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, @@ -912,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, } @@ -950,23 +1140,128 @@ def update_prefs( # @param [String] url URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. # # @return [Token] - def create_recovery( + def create_recovery( + email:, + url: + ) + if email.nil? + raise Appwrite::Exception.new('Missing required parameter: "email"') + end + + if url.nil? + raise Appwrite::Exception.new('Missing required parameter: "url"') + end + + api_path = '/account/recovery' + + api_params = { + email: email, + url: url, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Token + ) + end + + # Use this endpoint to complete the user account password reset. Both the + # **userId** and **secret** arguments will be passed as query parameters to + # the redirect URL you have provided when sending your request to the [POST + # /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) + # endpoint. + # + # Please note that in order to avoid a [Redirect + # Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + # the only valid redirect URLs are the ones from domains you have set when + # adding your platforms in the console interface. + # + # @param [String] user_id User ID. + # @param [String] secret Valid reset token. + # @param [String] password New user password. Must be between 8 and 256 chars. + # + # @return [Token] + def update_recovery( + user_id:, + secret:, + password: + ) + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if secret.nil? + raise Appwrite::Exception.new('Missing required parameter: "secret"') + end + + if password.nil? + raise Appwrite::Exception.new('Missing required parameter: "password"') + end + + api_path = '/account/recovery' + + api_params = { + userId: user_id, + secret: secret, + password: password, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Token + ) + end + + # Use this endpoint to send a 6-digit password recovery code to the user's + # email address. Unlike + # [createRecovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery), + # this method requires no redirect URL, which makes it suitable for mobile + # and desktop apps that cannot host a recovery page. Learn more about how to + # [complete the recovery + # process](https://appwrite.io/docs/references/cloud/client-web/account#updateRecoveryOTP). + # The code sent to the user's email address is valid for 15 minutes. + # + # Enable the **phrase** parameter to include a randomly generated security + # phrase in both the email and the response. Showing that phrase in your app + # lets the user confirm the email genuinely came from your request, which + # helps protect against phishing. + # + # + # @param [String] email User email. + # @param [] phrase Toggle for security phrase. If enabled, email will be sent with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + # + # @return [Token] + def create_recovery_otp( email:, - url: + phrase: nil ) - api_path = '/account/recovery' - if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end - if url.nil? - raise Appwrite::Exception.new('Missing required parameter: "url"') - end + api_path = '/account/recovery/otp' api_params = { email: email, - url: url, + phrase: phrase, } api_headers = { @@ -984,29 +1279,24 @@ def create_recovery( ) end - # Use this endpoint to complete the user account password reset. Both the - # **userId** and **secret** arguments will be passed as query parameters to - # the redirect URL you have provided when sending your request to the [POST - # /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) - # endpoint. + # Use this endpoint to complete the user password recovery process using the + # 6-digit code that was emailed by + # [createRecoveryOTP](https://appwrite.io/docs/references/cloud/client-web/account#createRecoveryOTP). + # Pass the **userId** of the user along with the **secret** code from the + # email and the new **password** to set. If confirmed, this route will return + # a 200 status code, the code is consumed and the user's password is updated. # - # Please note that in order to avoid a [Redirect - # Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) - # the only valid redirect URLs are the ones from domains you have set when - # adding your platforms in the console interface. # # @param [String] user_id User ID. - # @param [String] secret Valid reset token. + # @param [String] secret Valid recovery OTP code. # @param [String] password New user password. Must be between 8 and 256 chars. # # @return [Token] - def update_recovery( + def update_recovery_otp( user_id:, secret:, password: ) - api_path = '/account/recovery' - if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1019,6 +1309,8 @@ def update_recovery( raise Appwrite::Exception.new('Missing required parameter: "password"') end + api_path = '/account/recovery/otp' + api_params = { userId: user_id, secret: secret, @@ -1043,12 +1335,17 @@ def update_recovery( # Get the list of active sessions across different devices for the currently # logged in user. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [SessionList] - def list_sessions() + def list_sessions( + total: nil + ) api_path = '/account/sessions' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -1065,18 +1362,25 @@ 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. # # @return [] - def delete_sessions() + def delete_sessions( + current: nil + ) api_path = '/account/sessions' - api_params = {} + api_params = { + current: current, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1119,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 @@ -1126,14 +1433,14 @@ def create_anonymous_session() # # @param [String] email User email. # @param [String] password User password. Must be at least 8 chars. + # @param [Integer] duration Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length. # # @return [Session] def create_email_password_session( email:, - password: + password:, + duration: nil ) - api_path = '/account/sessions/email' - if email.nil? raise Appwrite::Exception.new('Missing required parameter: "email"') end @@ -1142,9 +1449,105 @@ 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, + duration: duration, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Session + ) + end + + # Allow the user to login to their account using an OpenID Connect ID token + # obtained natively from the OAuth2 provider, for example via Google + # Credential Manager on Android or Sign in with Apple on iOS. No browser or + # redirect is involved: the ID token is verified against the provider's + # published signing keys and a session is created in a single request. + # + # Native sign-in is switched on per provider with its nativeEnabled setting. + # It is independent of the browser-based flow's enabled setting, which has no + # effect on this endpoint. The token's audience must match the provider's + # configured client ID or one of its native client IDs; tokens issued for any + # other client ID are rejected. For Sign in with Apple, register your app's + # bundle ID as a native client ID. For Google, the web client ID used by + # Credential Manager is usually the configured client ID; add your Android + # and iOS client IDs as native client IDs if your app requests tokens for + # them. + # + # Pass the raw nonce used when requesting the ID token so it can be validated + # against the token's nonce claim. When signing in with Apple, the nonce is + # required: hash it with SHA-256 before passing it to the Apple SDK, and send + # the raw value here - Apple tokens requested without a nonce are rejected. + # For Google the nonce is optional: it is validated whenever the token + # carries one, and ignored when the provider issued the token without one. + # Apple only returns the user's name on the first authorization, and never + # inside the ID token - capture it on the client and pass it via the name + # parameter. + # + # If there is already an active session, the new session will be attached to + # the logged-in account. If there are no active sessions, the server will + # attempt to look for a user with the same email address as the verified + # email received from the provider and attach the new session to the existing + # user. If no matching user is found - the server will create a new user. + # + # This flow does not return provider refresh tokens. You may pass an access + # token the provider handed your client, along with its lifetime, to store it + # on the session - but Appwrite cannot renew it once it expires. If your app + # needs long-lived access to provider APIs, use the browser-based OAuth2 flow + # instead. + # + # A user is limited to 10 active sessions at a time by default. [Learn more + # about session + # limits](https://appwrite.io/docs/authentication-security#limits). + # + # + # @param [IdTokenProvider] provider OAuth2 provider that issued the ID token. Currently, supported providers are: apple, google. + # @param [String] id_token OpenID Connect ID token (JWT) obtained natively from the provider, for example via Google Credential Manager or Sign in with Apple. + # @param [String] nonce Raw nonce used when requesting the ID token. Required for Apple, and whenever the token carries a nonce claim, which must match it. Ignored when the provider issued the token without a nonce. + # @param [String] access_token Provider access token to store alongside the session for calling provider APIs. Never used for authentication. + # @param [Integer] access_token_expiry Seconds until the provider access token expires, as reported by the provider. Stored so clients can tell when the stored token goes stale. + # @param [String] name User name. Only used when creating a new user and the ID token has no name claim, such as on the first Sign in with Apple authorization. + # + # @return [Session] + def create_id_token_session( + provider:, + id_token:, + nonce: nil, + access_token: nil, + access_token_expiry: nil, + name: nil + ) + if provider.nil? + raise Appwrite::Exception.new('Missing required parameter: "provider"') + end + + if id_token.nil? + raise Appwrite::Exception.new('Missing required parameter: "idToken"') + end + + api_path = '/account/sessions/id-token' + + api_params = { + provider: provider, + idToken: id_token, + nonce: nonce, + accessToken: access_token, + accessTokenExpiry: access_token_expiry, + name: name, } api_headers = { @@ -1177,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 @@ -1187,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, @@ -1222,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 @@ -1232,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, @@ -1264,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 @@ -1274,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, @@ -1303,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 = { @@ -1336,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 = { @@ -1372,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( @@ -1445,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 @@ -1455,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, @@ -1503,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 @@ -1513,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, @@ -1546,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. @@ -1564,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, @@ -1592,6 +2000,84 @@ def create_o_auth2_token( ) end + # Start signing in with a passkey. No email or user ID is needed: pass the + # returned `publicKey` options to `navigator.credentials.get()` and the user + # picks one of their passkeys. Then call [Update passkey + # token](/docs/references/cloud/client-web/account#updatePasskeyToken) with + # the credential to receive a token, and exchange it with [Create + # session](/docs/references/cloud/client-web/account#createSession). The + # challenge expires after 5 minutes. + # + # + # @return [PasskeyChallenge] + def create_passkey_token() + api_path = '/account/tokens/passkey' + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::PasskeyChallenge + ) + end + + # Complete a passkey sign-in started with [Create passkey + # token](/docs/references/cloud/client-web/account#createPasskeyToken). Pass + # the challenge ID and the JSON form of the credential returned by + # `navigator.credentials.get()`, for example `credential.toJSON()`. The + # returned token includes its secret and expires after 1 minute: exchange it + # for a session with [Create + # session](/docs/references/cloud/client-web/account#createSession). Passkeys + # require user verification, so the session also satisfies MFA. Each + # challenge can only be used once. + # + # @param [String] challenge_id Challenge ID returned by createPasskeyToken. + # @param [Hash] credential Authentication credential returned by the authenticator, in the JSON form produced by `PublicKeyCredential.toJSON()`. + # + # @return [TokenSecret] + def update_passkey_token( + challenge_id:, + credential: + ) + if challenge_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "challengeId"') + end + + if credential.nil? + raise Appwrite::Exception.new('Missing required parameter: "credential"') + end + + api_path = '/account/tokens/passkey' + + api_params = { + challengeId: challenge_id, + credential: credential, + } + + 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::TokenSecret + ) + end + # Sends the user an SMS with a secret key for creating a session. If the # provided user ID has not be registered, a new user will be created. Use the # returned user ID and secret and submit a request to the [POST @@ -1611,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 @@ -1621,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, @@ -1663,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, } @@ -1713,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, } @@ -1751,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 @@ -1761,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, @@ -1797,8 +2283,94 @@ def update_verification( user_id:, secret: ) + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if secret.nil? + raise Appwrite::Exception.new('Missing required parameter: "secret"') + end + api_path = '/account/verifications/email' + api_params = { + userId: user_id, + secret: secret, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Token + ) + end + + # Use this endpoint to send a 6-digit verification code to the currently + # logged in user's email address. Unlike + # [createEmailVerification](https://appwrite.io/docs/references/cloud/client-web/account#createEmailVerification), + # this method requires no redirect URL, which makes it suitable for mobile + # and desktop apps that cannot host a verification page. Learn more about how + # to [complete the verification + # process](https://appwrite.io/docs/references/cloud/client-web/account#updateEmailVerificationOTP). + # The code sent to the user's email address is valid for 15 minutes. + # + # Enable the **phrase** parameter to include a randomly generated security + # phrase in both the email and the response. Showing that phrase in your app + # lets the user confirm the email genuinely came from your request, which + # helps protect against phishing. + # + # + # @param [] phrase Toggle for security phrase. If enabled, email will be sent with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + # + # @return [Token] + def create_email_verification_otp( + phrase: nil + ) + api_path = '/account/verifications/email/otp' + + api_params = { + phrase: phrase, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Token + ) + end + + # Use this endpoint to complete the user email verification process using the + # 6-digit code that was emailed by + # [createEmailVerificationOTP](https://appwrite.io/docs/references/cloud/client-web/account#createEmailVerificationOTP). + # Pass the **userId** of the user being verified along with the **secret** + # code from the email. If confirmed, this route will return a 200 status code + # and the code is consumed. + # + # + # @param [String] user_id User ID. + # @param [String] secret Valid verification OTP code. + # + # @return [Token] + def update_email_verification_otp( + user_id:, + secret: + ) if user_id.nil? raise Appwrite::Exception.new('Missing required parameter: "userId"') end @@ -1807,6 +2379,8 @@ def update_verification( raise Appwrite::Exception.new('Missing required parameter: "secret"') end + api_path = '/account/verifications/email/otp' + api_params = { userId: user_id, secret: secret, @@ -1871,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 @@ -1881,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 42f27720..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, @@ -346,6 +346,77 @@ def get_photo( ) end + # Update the profile photo of the currently authenticated user. The uploaded + # image takes priority over every other photo source, including OAuth2 + # identity photos, Gravatar, and Libravatar. Updating an already customized + # photo replaces it. The image must be at most 5MB and is sent in a single + # request. + # + # @param [file] file Binary image file of at most 5MB. Allowed file types are png, jpg, jpeg, and webp. + # + # @return [Account] + def update_photo( + file:, + on_progress: nil + ) + if file.nil? + raise Appwrite::Exception.new('Missing required parameter: "file"') + end + + api_path = '/avatars/photo' + + api_params = { + file: file, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'multipart/form-data', + "accept": 'application/json', + } + + id_param_name = nil + param_name = 'file' + + @client.chunked_upload( + path: api_path, + headers: api_headers, + params: api_params, + param_name: param_name, + id_param_name: id_param_name, + on_progress: on_progress, + method: 'PUT', + response_type: Models::Account + ) + end + + # Delete the profile photo of the currently authenticated user and store the + # built-in static placeholder in its place. The placeholder is the user's + # photo from then on, so it takes priority over every other photo source — + # OAuth2 identity photos, Gravatar, Libravatar, and initials — until a new + # photo is uploaded with avatars.updatePhoto. + # + # + # @return [] + def delete_photo() + api_path = '/avatars/photo' + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + end + # Converts a given plain text to a QR code image. You can use the query # parameters to change the size and style of the resulting image. # @@ -362,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, @@ -400,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. @@ -443,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 414f91cd..ff21ca97 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, @@ -97,15 +97,18 @@ def create( # List transactions across all databases. # # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [TransactionList] def list_transactions( - queries: nil + queries: nil, + total: nil ) api_path = '/databases/transactions' api_params = { queries: queries, + total: total, } api_headers = { @@ -165,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 = { @@ -203,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, @@ -241,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( @@ -276,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, } @@ -314,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 = { @@ -352,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, @@ -391,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( @@ -431,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, @@ -486,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 @@ -501,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, @@ -540,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 = { @@ -591,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, @@ -640,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( @@ -684,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, @@ -742,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 @@ -762,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, @@ -813,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 @@ -838,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, @@ -883,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 @@ -903,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, @@ -947,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 @@ -972,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, @@ -1014,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 @@ -1034,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, @@ -1078,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 @@ -1103,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, @@ -1146,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 @@ -1166,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, @@ -1211,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 @@ -1236,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, @@ -1282,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 @@ -1306,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, @@ -1354,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 @@ -1383,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, @@ -1432,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 @@ -1452,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, @@ -1503,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 @@ -1528,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, @@ -1578,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 @@ -1598,8 +1600,12 @@ def create_integer_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end - api_params = { - key: key, + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + + api_params = { + key: key, required: required, min: min, max: max, @@ -1649,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 @@ -1674,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, @@ -1719,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 @@ -1739,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, @@ -1784,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 @@ -1809,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, @@ -1849,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 @@ -1869,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, @@ -1912,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 @@ -1933,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, @@ -1978,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 @@ -1998,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, @@ -2044,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 @@ -2069,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, @@ -2114,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 @@ -2134,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, @@ -2180,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 @@ -2205,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, @@ -2245,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 @@ -2265,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, @@ -2308,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 @@ -2329,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, @@ -2369,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 @@ -2389,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, @@ -2432,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 @@ -2453,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, @@ -2501,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 @@ -2521,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, @@ -2566,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, @@ -2629,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 @@ -2653,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, @@ -2702,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 @@ -2727,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, @@ -2773,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 @@ -2793,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, @@ -2839,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 @@ -2864,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, @@ -2907,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 @@ -2927,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, @@ -2972,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 @@ -2997,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, @@ -3044,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 @@ -3068,7 +3070,11 @@ def create_varchar_attribute( raise Appwrite::Exception.new('Missing required parameter: "required"') end - api_params = { + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + + api_params = { key: key, size: size, required: required, @@ -3117,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 @@ -3142,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, @@ -3173,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 = { @@ -3239,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) @@ -3259,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) @@ -3282,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( @@ -3336,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, @@ -3393,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 @@ -3413,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, @@ -3455,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 @@ -3471,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, @@ -3512,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 @@ -3528,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, @@ -3569,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, @@ -3620,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, @@ -3672,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, @@ -3732,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, @@ -3792,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, @@ -3847,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, } @@ -3871,6 +3918,7 @@ def delete_document( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -3904,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, @@ -3970,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, @@ -4030,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, @@ -4086,15 +4134,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 @@ -4110,6 +4154,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, @@ -4148,23 +4196,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 = { @@ -4196,28 +4244,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 09237e92..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] @@ -119,15 +119,18 @@ def list_specifications() # List transactions across all databases. # # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [TransactionList] def list_transactions( - queries: nil + queries: nil, + total: nil ) api_path = '/documentsdb/transactions' api_params = { queries: queries, + total: total, } api_headers = { @@ -181,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 = { @@ -216,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, @@ -251,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( @@ -283,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, } @@ -318,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 = { @@ -359,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 @@ -370,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, @@ -402,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( @@ -439,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, @@ -491,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 @@ -506,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, @@ -542,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 = { @@ -590,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 @@ -606,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, @@ -640,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( @@ -686,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, @@ -740,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 @@ -760,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, @@ -799,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 @@ -815,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, @@ -853,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 @@ -869,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, @@ -907,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, @@ -955,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, @@ -1004,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, @@ -1061,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, @@ -1118,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, @@ -1170,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, } @@ -1194,6 +1200,7 @@ def delete_document( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1224,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, @@ -1287,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, @@ -1344,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, @@ -1397,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 @@ -1421,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, @@ -1456,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 = { @@ -1501,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( @@ -1551,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, } @@ -1594,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, @@ -1630,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 = { @@ -1663,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 new file mode 100644 index 00000000..42937c7d --- /dev/null +++ b/lib/appwrite/services/domains.rb @@ -0,0 +1,2318 @@ +# frozen_string_literal: true + +module Appwrite + class Domains < Service + def initialize(client) + @client = client + end + + # List all domains registered for this project. This endpoint supports + # pagination. + # + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as domain name, teamInternalId, expiration, etc. + # @param [String] search Search term to filter your list results. Max length: 256 chars. + # + # @return [DomainsList] + def list( + queries: nil, + search: nil + ) + api_path = '/domains' + + api_params = { + queries: queries, + search: search, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DomainsList + ) + end + + # Create a new domain. Before creating a domain, you need to ensure that your + # DNS provider is properly configured. After creating the domain, you can use + # the verification endpoint to check if the domain is ready to be used. + # + # @param [String] team_id Team unique ID. + # @param [String] domain Domain name (e.g. "example.com"). + # + # @return [Domain] + def create( + team_id:, + domain: + ) + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + + if domain.nil? + raise Appwrite::Exception.new('Missing required parameter: "domain"') + end + + api_path = '/domains' + + api_params = { + teamId: team_id, + domain: domain, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Domain + ) + end + + # + # @deprecated This API has been deprecated since 2.0.0. Please use `Domains.listPrices` instead. + # + # Get the registration price for a domain name. + # + # @param [String] domain Domain name to get price for. + # @param [Integer] period_years Number of years to calculate the domain price for. Must be at least 1. + # @param [DomainRegistrationType] registration_type Type of registration pricing to fetch. Allowed values: new, transfer, renewal, trade. + # + # @return [DomainPrice] + def get_price( + domain:, + period_years: nil, + registration_type: nil + ) + if domain.nil? + raise Appwrite::Exception.new('Missing required parameter: "domain"') + end + + api_path = '/domains/price' + + api_params = { + domain: domain, + periodYears: period_years, + registrationType: registration_type, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DomainPrice + ) + end + + # Check availability and get the requested registration price for one or more + # domain names. Availability is resolved for all domains in a single + # registrar lookup. Unavailable domains have a null price for new + # registrations, but can still be priced for renewal, transfer, or trade. + # Every priced domain also carries its renewal price for the same period, so + # a separate renewal lookup is not needed. A domain whose price could not be + # resolved, for example because its TLD is not supported, is returned with a + # null price. + # + # @param [Array] domains Domain names to check availability and price for. Maximum of 50 domains per request. + # @param [Integer] period_years Number of years to calculate the domain price for. Must be at least 1. + # @param [DomainRegistrationType] registration_type Type of registration pricing to fetch. Allowed values: new, transfer, renewal, trade. + # + # @return [DomainPricesList] + def list_prices( + domains:, + period_years: nil, + registration_type: nil + ) + if domains.nil? + raise Appwrite::Exception.new('Missing required parameter: "domains"') + end + + api_path = '/domains/prices' + + api_params = { + domains: domains, + periodYears: period_years, + registrationType: registration_type, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DomainPricesList + ) + end + + # Get a domain by its unique ID. + # + # @param [String] domain_id Domain unique ID. + # + # @return [Domain] + def get( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Domain + ) + end + + # Delete a domain by its unique ID. This endpoint can be used to delete a + # domain from your project. + # Once deleted, the domain will no longer be available for use and all + # associated resources will be removed. + # + # @param [String] domain_id Domain unique ID. + # + # @return [] + def delete( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + end + + # Update the registrar nameservers for the given domain. When nameservers are + # not provided, + # the domain will be updated to use Appwrite nameservers. + # + # @param [String] domain_id Domain unique ID. + # @param [Array] nameservers Nameservers to set for the domain. Defaults to Appwrite nameservers when omitted. + # + # @return [Domain] + def update_nameservers( + domain_id:, + nameservers: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/nameservers' + .gsub('{domainId}', domain_id) + + api_params = { + nameservers: nameservers, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Domain + ) + end + + # Verify which NS records are used and update the domain accordingly. This + # will check the domain's + # nameservers and update the domain's status based on whether the nameservers + # match the expected + # Appwrite nameservers. + # + # @param [String] domain_id Domain unique ID. + # + # @return [Domain] + def verify_nameservers( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/nameservers/verification' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Domain + ) + end + + # List Google Workspace DNS records. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def get_preset_google_workspace( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/google-workspace' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # Add Google Workspace DNS records to the domain. This will create the + # required MX records + # for Google Workspace email hosting. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def create_preset_google_workspace( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/google-workspace' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # List iCloud DNS records. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def get_preset_i_cloud( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/icloud' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # Add iCloud DNS records to the domain. This will create the required MX and + # SPF records + # for using iCloud email services with your domain. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def create_preset_i_cloud( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/icloud' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # List Mailgun DNS records. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def get_preset_mailgun( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/mailgun' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # Add Mailgun DNS records to the domain. This endpoint will create the + # required DNS records + # for Mailgun in the specified domain. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def create_preset_mailgun( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/mailgun' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # List Outlook DNS records. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def get_preset_outlook( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/outlook' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # Add Outlook DNS records to the domain. This will create the required MX + # records + # for setting up Outlook email hosting for your domain. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def create_preset_outlook( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/outlook' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # List ProtonMail DNS records. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def get_preset_proton_mail( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/proton-mail' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # Add ProtonMail DNS records to the domain. This will create the required MX + # records + # for using ProtonMail with your custom domain. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def create_preset_proton_mail( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/proton-mail' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # List Zoho DNS records. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def get_preset_zoho( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/zoho' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # Add Zoho Mail DNS records to the domain. This will create the required MX + # records + # for setting up Zoho Mail on your domain. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DnsRecordsList] + def create_preset_zoho( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/presets/zoho' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # List DNS records for a given domain. You can use this endpoint to list all + # the DNS records + # associated with your domain. + # + # @param [String] domain_id Domain unique ID. + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. You may filter on attributes such as type, name, value, etc. Maximum of 100 queries are allowed, each 4096 characters long. + # + # @return [DnsRecordsList] + def list_records( + domain_id:, + queries: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/records' + .gsub('{domainId}', domain_id) + + api_params = { + queries: queries, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecordsList + ) + end + + # Create a new A record for the given domain. A records are used to point a + # domain name + # to an IPv4 address. The record value should be a valid IPv4 address. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value IPv4 address for this A record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment explaining what this record is for. + # + # @return [DnsRecord] + def create_record_a( + domain_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/a' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing A record for the given domain. This endpoint allows you + # to modify + # the properties of an A record including its name (subdomain), IPv4 address, + # TTL, + # and optional comment. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value IPv4 address for this A record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment explaining what this record is for. + # + # @return [DnsRecord] + def update_record_a( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? || record_id == '' + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/a/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new AAAA record for the given domain. This endpoint allows you to + # add a new IPv6 DNS record + # to your domain. The record will be used to point a hostname to an IPv6 + # address. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value IPv6 address for this AAAA record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment explaining what this record is for. + # + # @return [DnsRecord] + def create_record_aaaa( + domain_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/aaaa' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing AAAA record for the given domain. This endpoint allows + # you to modify + # the properties of an existing AAAA record, including its name (subdomain), + # IPv6 address, + # TTL, and optional comment. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value IPv6 address for this AAAA record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_aaaa( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? || record_id == '' + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/aaaa/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new ALIAS record for the given domain. This record type can be + # used to point your domain + # to another domain name that will serve as an alias. This is particularly + # useful when you want to + # map your domain to a target domain that may change its IP address. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name. + # @param [String] value Target domain for this ALIAS record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_alias( + domain_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/alias' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing ALIAS record for the specified domain. This endpoint + # allows you to modify + # the properties of an existing ALIAS record including its name, target + # domain, TTL, and comment. + # + # The ALIAS record type is similar to a CNAME record but can be used at the + # zone apex (root domain). + # It provides a way to map one domain name to another. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name. + # @param [String] value Target domain for this ALIAS record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_alias( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? || record_id == '' + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/alias/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new CAA record for the given domain. CAA records are used to + # specify which + # Certificate Authorities (CAs) are allowed to issue SSL/TLS certificates for + # your domain. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name. + # @param [String] value CAA value (e.g. issuer domain). + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_caa( + domain_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/caa' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing CAA record for the given domain. A CAA (Certification + # Authority Authorization) + # record is used to specify which certificate authorities (CAs) are + # authorized to issue certificates + # for a domain. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name. + # @param [String] value CAA value (e.g. issuer domain). + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_caa( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? || record_id == '' + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/caa/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new CNAME record for the given domain. + # + # A CNAME record maps a subdomain to another domain name, allowing you to + # create aliases + # for your domain. For example, you can create a CNAME record to point + # 'blog.example.com' + # to 'example.wordpress.com'. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Canonical target for this CNAME record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_cname( + domain_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/cname' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing CNAME record for the given domain. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Canonical target for this CNAME record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_cname( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? || record_id == '' + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/cname/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new HTTPS record for the given domain. This record is used to + # configure HTTPS + # settings for your domain, enabling secure communication over SSL/TLS. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Target for the HTTPS record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_https( + domain_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/https' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing HTTPS record for the given domain. This endpoint allows + # you to modify + # the properties of an HTTPS record associated with your domain, including + # the name (subdomain), + # target value, TTL, and optional comment. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Target for the HTTPS record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_https( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? || record_id == '' + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/https/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new MX record for the given domain. MX records are used to define + # the mail servers responsible + # for accepting email messages for the domain. Multiple MX records can be + # created with different priorities. + # The priority parameter determines the order in which mail servers are used, + # with lower values indicating + # higher priority. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Mail server domain for this MX record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [Integer] priority MX priority. Lower values are tried first. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_mx( + domain_id:, + name:, + value:, + ttl:, + priority:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + if priority.nil? + raise Appwrite::Exception.new('Missing required parameter: "priority"') + end + + api_path = '/domains/{domainId}/records/mx' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + priority: priority, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing MX record for the given domain. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Mail server domain for this MX record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [Integer] priority MX priority. Lower values are tried first. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_mx( + domain_id:, + record_id:, + name:, + value:, + ttl:, + priority:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? || record_id == '' + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + if priority.nil? + raise Appwrite::Exception.new('Missing required parameter: "priority"') + end + + api_path = '/domains/{domainId}/records/mx/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + priority: priority, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new NS record for the given domain. NS records specify the + # nameservers that are used + # to resolve the domain name to IP addresses. Each domain can have multiple + # NS records. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Nameserver target for this NS record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_ns( + domain_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/ns' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing NS record for the given domain. This endpoint allows you + # to modify + # the properties of an NS (nameserver) record associated with your domain. + # You can update + # the record name (subdomain), target nameserver value, TTL, and add or + # modify comments + # for better record management. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (subdomain). + # @param [String] value Nameserver target for this NS record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_ns( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? || record_id == '' + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/ns/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new SRV record for the given domain. SRV records are used to + # define the location + # of servers for specific services. For example, they can be used to specify + # which server + # handles a specific service like SIP or XMPP for the domain. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (service name). + # @param [String] value Target hostname for this SRV record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [Integer] priority Record priority. Lower values are tried first. + # @param [Integer] weight Record weight, used to share load between targets of equal priority. + # @param [Integer] port Port number for the service. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_srv( + domain_id:, + name:, + value:, + ttl:, + priority:, + weight:, + port:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + if priority.nil? + raise Appwrite::Exception.new('Missing required parameter: "priority"') + end + + if weight.nil? + raise Appwrite::Exception.new('Missing required parameter: "weight"') + end + + if port.nil? + raise Appwrite::Exception.new('Missing required parameter: "port"') + end + + api_path = '/domains/{domainId}/records/srv' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + priority: priority, + weight: weight, + port: port, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing SRV record for the given domain. + # + # Required parameters: + # - domainId: Domain unique ID + # - recordId: DNS record unique ID + # - name: Record name (service name) + # - value: Target hostname for this SRV record + # - ttl: Time to live, in seconds + # - priority: Record priority + # - weight: Record weight + # - port: Port number for the service + # + # Optional parameters: + # - comment: A comment for this record + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (service name). + # @param [String] value Target hostname for this SRV record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [Integer] priority Record priority. Lower values are tried first. + # @param [Integer] weight Record weight, used to share load between targets of equal priority. + # @param [Integer] port Port number for the service. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_srv( + domain_id:, + record_id:, + name:, + value:, + ttl:, + priority:, + weight:, + port:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? || record_id == '' + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + if priority.nil? + raise Appwrite::Exception.new('Missing required parameter: "priority"') + end + + if weight.nil? + raise Appwrite::Exception.new('Missing required parameter: "weight"') + end + + if port.nil? + raise Appwrite::Exception.new('Missing required parameter: "port"') + end + + api_path = '/domains/{domainId}/records/srv/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + priority: priority, + weight: weight, + port: port, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Create a new TXT record for the given domain. TXT records can be used + # to provide additional information about your domain, such as domain + # verification records, SPF records, or DKIM records. + # + # @param [String] domain_id Domain unique ID. + # @param [String] name Record name (subdomain) for the TXT record. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] value TXT record value. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def create_record_txt( + domain_id:, + name:, + ttl:, + value: nil, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/txt' + .gsub('{domainId}', domain_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Update an existing TXT record for the given domain. + # + # Update the TXT record details for a specific domain by providing the domain + # ID, + # record ID, and the new record configuration including name, value, TTL, and + # an optional comment. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # @param [String] name Record name (subdomain) for the TXT record. + # @param [String] value TXT record value. + # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647. + # @param [String] comment A comment for this record. + # + # @return [DnsRecord] + def update_record_txt( + domain_id:, + record_id:, + name:, + value:, + ttl:, + comment: nil + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? || record_id == '' + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if value.nil? + raise Appwrite::Exception.new('Missing required parameter: "value"') + end + + if ttl.nil? + raise Appwrite::Exception.new('Missing required parameter: "ttl"') + end + + api_path = '/domains/{domainId}/records/txt/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = { + name: name, + value: value, + ttl: ttl, + comment: comment, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Get a single DNS record for a given domain by record ID. + # + # This endpoint allows you to retrieve a specific DNS record associated with + # a domain + # using its unique identifier. The record contains information about the DNS + # configuration + # such as type, value, and TTL settings. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # + # @return [DnsRecord] + def get_record( + domain_id:, + record_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? || record_id == '' + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + api_path = '/domains/{domainId}/records/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DnsRecord + ) + end + + # Delete a DNS record for the given domain. This endpoint allows you to + # delete an existing DNS record + # from a specific domain. + # + # @param [String] domain_id Domain unique ID. + # @param [String] record_id DNS record unique ID. + # + # @return [] + def delete_record( + domain_id:, + record_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if record_id.nil? || record_id == '' + raise Appwrite::Exception.new('Missing required parameter: "recordId"') + end + + api_path = '/domains/{domainId}/records/{recordId}' + .gsub('{domainId}', domain_id) + .gsub('{recordId}', record_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + end + + # Update the team ID for a specific domain. The caller must administer the + # current + # team and be an owner of the destination team. + # + # Updating the team ID will transfer ownership and access control of the + # domain + # and all its DNS records to the new team. + # + # @param [String] domain_id Domain unique ID. + # @param [String] team_id New team unique ID. + # + # @return [Domain] + def update_team( + domain_id:, + team_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + + api_path = '/domains/{domainId}/team' + .gsub('{domainId}', domain_id) + + api_params = { + teamId: team_id, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Domain + ) + end + + # Retrieve the current transfer status for a domain. Returns the status, an + # optional reason, and a timestamp of the last status change. + # + # @param [String] domain_id Domain unique ID. + # + # @return [DomainTransferStatus] + def get_transfer_status( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/transfers/status' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DomainTransferStatus + ) + end + + # Retrieve the DNS zone file for the given domain. This endpoint will return + # the DNS + # zone file in a standardized format that can be used to configure DNS + # servers. + # + # @param [String] domain_id Domain unique ID. + # + # @return [String] + def get_zone( + domain_id: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + api_path = '/domains/{domainId}/zone' + .gsub('{domainId}', domain_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'text/plain', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: "text" + ) + end + + # Update the DNS zone for the given domain using the provided zone file + # content. + # All parsed records are imported and then the main domain document is + # returned. + # + # @param [String] domain_id Domain unique ID. + # @param [String] content DNS zone file content as a string. + # + # @return [Domain] + def update_zone( + domain_id:, + content: + ) + if domain_id.nil? || domain_id == '' + raise Appwrite::Exception.new('Missing required parameter: "domainId"') + end + + if content.nil? + raise Appwrite::Exception.new('Missing required parameter: "content"') + end + + api_path = '/domains/{domainId}/zone' + .gsub('{domainId}', domain_id) + + api_params = { + content: content, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Domain + ) + end + end +end diff --git a/lib/appwrite/services/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 52ceb963..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, @@ -153,12 +153,17 @@ def create( # Get a list of all runtimes that are currently active on your instance. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [RuntimeList] - def list_runtimes() + def list_runtimes( + total: nil + ) api_path = '/functions/runtimes' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -177,15 +182,18 @@ def list_runtimes() # List allowed function specifications for this instance. # # @param [String] type Specification type to list. Can be one of: runtimes, builds. Defaults to runtimes. + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [SpecificationList] def list_specifications( - type: nil + type: nil, + total: nil ) api_path = '/functions/specifications' api_params = { type: type, + total: total, } api_headers = { @@ -210,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 = { @@ -285,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 @@ -296,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, @@ -344,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( @@ -377,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 @@ -388,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, } @@ -422,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, @@ -475,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 @@ -490,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, @@ -513,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 @@ -533,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 @@ -544,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, @@ -588,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 @@ -615,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, @@ -655,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 @@ -670,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, @@ -701,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 = { @@ -739,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( @@ -782,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, @@ -826,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 = { @@ -868,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, @@ -917,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, @@ -958,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 = { @@ -996,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( @@ -1035,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, @@ -1078,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 @@ -1097,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, @@ -1129,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 = { @@ -1173,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, @@ -1216,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/locale.rb b/lib/appwrite/services/locale.rb index 3728751b..8a50531a 100644 --- a/lib/appwrite/services/locale.rb +++ b/lib/appwrite/services/locale.rb @@ -37,12 +37,17 @@ def get() # List of all locale codes in [ISO # 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [LocaleCodeList] - def list_codes() + def list_codes( + total: nil + ) api_path = '/locale/codes' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -61,12 +66,17 @@ def list_codes() # List of all continents. You can use the locale header to get the data in a # supported language. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [ContinentList] - def list_continents() + def list_continents( + total: nil + ) api_path = '/locale/continents' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -85,12 +95,17 @@ def list_continents() # List of all countries. You can use the locale header to get the data in a # supported language. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [CountryList] - def list_countries() + def list_countries( + total: nil + ) api_path = '/locale/countries' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -109,12 +124,17 @@ def list_countries() # List of all countries that are currently members of the EU. You can use the # locale header to get the data in a supported language. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [CountryList] - def list_countries_eu() + def list_countries_eu( + total: nil + ) api_path = '/locale/countries/eu' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -133,12 +153,17 @@ def list_countries_eu() # List of all countries phone codes. You can use the locale header to get the # data in a supported language. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [PhoneList] - def list_countries_phones() + def list_countries_phones( + total: nil + ) api_path = '/locale/countries/phones' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -158,12 +183,17 @@ def list_countries_phones() # decimal digits for all major and minor currencies. You can use the locale # header to get the data in a supported language. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [CurrencyList] - def list_currencies() + def list_currencies( + total: nil + ) api_path = '/locale/currencies' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -182,12 +212,17 @@ def list_currencies() # List of all languages classified by ISO 639-1 including 2-letter code, name # in English, and name in the respective language. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [LanguageList] - def list_languages() + def list_languages( + total: nil + ) api_path = '/locale/languages' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), diff --git a/lib/appwrite/services/messaging.rb b/lib/appwrite/services/messaging.rb index 30ab729f..e3c86700 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. # @@ -51,6 +51,8 @@ def list_messages( # @param [Array] cc Array of target IDs to be added as CC. # @param [Array] bcc Array of target IDs to be added as BCC. # @param [Array] attachments Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + # @param [String] reply_to_email Email address to reply to. If not set, defaults to the sender email address. + # @param [String] reply_to_name Name of the reply to recipient. If not set, defaults to the sender name. # @param [] draft Is message a draft # @param [] html Is content of type HTML # @param [String] scheduled_at Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. @@ -66,12 +68,12 @@ def create_email( cc: nil, bcc: nil, attachments: nil, + reply_to_email: nil, + reply_to_name: nil, draft: nil, html: nil, scheduled_at: nil ) - api_path = '/messaging/messages/email' - if message_id.nil? raise Appwrite::Exception.new('Missing required parameter: "messageId"') end @@ -84,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, @@ -94,6 +98,8 @@ def create_email( cc: cc, bcc: bcc, attachments: attachments, + replyToEmail: reply_to_email, + replyToName: reply_to_name, draft: draft, html: html, scheduledAt: scheduled_at, @@ -120,52 +126,58 @@ def create_email( # # # @param [String] message_id Message ID. + # @param [String] subject Email Subject. + # @param [String] content Email Content. # @param [Array] topics List of Topic IDs. # @param [Array] users List of User IDs. # @param [Array] targets List of Targets IDs. - # @param [String] subject Email Subject. - # @param [String] content Email Content. - # @param [] draft Is message a draft - # @param [] html Is content of type HTML # @param [Array] cc Array of target IDs to be added as CC. # @param [Array] bcc Array of target IDs to be added as BCC. - # @param [String] scheduled_at Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. # @param [Array] attachments Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + # @param [String] reply_to_email Email address to reply to. Pass an empty string to restore the provider or sender default. + # @param [String] reply_to_name Name of the reply to recipient. Pass an empty string to restore the provider or sender default. + # @param [] draft Is message a draft + # @param [] html Is content of type HTML + # @param [String] scheduled_at Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. # # @return [Message] def update_email( message_id:, + subject: nil, + content: nil, topics: nil, users: nil, targets: nil, - subject: nil, - content: nil, - draft: nil, - html: nil, cc: nil, bcc: nil, - scheduled_at: nil, - attachments: nil + attachments: nil, + reply_to_email: nil, + reply_to_name: nil, + draft: nil, + html: nil, + scheduled_at: 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 = { + subject: subject, + content: content, topics: topics, users: users, targets: targets, - subject: subject, - content: content, - draft: draft, - html: html, cc: cc, bcc: bcc, - scheduledAt: scheduled_at, attachments: attachments, + replyToEmail: reply_to_email, + replyToName: reply_to_name, + draft: draft, + html: html, + scheduledAt: scheduled_at, } api_headers = { @@ -204,6 +216,7 @@ def update_email( # @param [] content_available If set to true, the notification will be delivered in the background. Available only for iOS Platform. # @param [] critical If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. # @param [MessagePriority] priority Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. + # @param [String] channel_id ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Available only for Android Platform. # # @return [Message] def create_push( @@ -225,14 +238,15 @@ def create_push( scheduled_at: nil, content_available: nil, critical: nil, - priority: nil + 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, @@ -253,6 +267,7 @@ def create_push( contentAvailable: content_available, critical: critical, priority: priority, + channelId: channel_id, } api_headers = { @@ -276,11 +291,11 @@ def create_push( # # # @param [String] message_id Message ID. + # @param [String] title Title for push notification. + # @param [String] body Body for push notification. # @param [Array] topics List of Topic IDs. # @param [Array] users List of User IDs. # @param [Array] targets List of Targets IDs. - # @param [String] title Title for push notification. - # @param [String] body Body for push notification. # @param [Hash] data Additional Data for push notification. # @param [String] action Action for push notification. # @param [String] image Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. @@ -294,15 +309,16 @@ def create_push( # @param [] content_available If set to true, the notification will be delivered in the background. Available only for iOS Platform. # @param [] critical If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. # @param [MessagePriority] priority Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + # @param [String] channel_id ID of the notification channel to deliver the notification on. The app must have already created a channel with this ID, otherwise the channel from the app manifest is used. Pass an empty string to clear it. Available only for Android platforms. # # @return [Message] def update_push( message_id:, + title: nil, + body: nil, topics: nil, users: nil, targets: nil, - title: nil, - body: nil, data: nil, action: nil, image: nil, @@ -315,21 +331,22 @@ def update_push( scheduled_at: nil, content_available: nil, critical: nil, - priority: nil + priority: nil, + channel_id: nil ) - api_path = '/messaging/messages/push/{messageId}' - .gsub('{messageId}', message_id) - - 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 = { + title: title, + body: body, topics: topics, users: users, targets: targets, - title: title, - body: body, data: data, action: action, image: image, @@ -343,6 +360,7 @@ def update_push( contentAvailable: content_available, critical: critical, priority: priority, + channelId: channel_id, } api_headers = { @@ -380,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 @@ -390,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, @@ -421,35 +439,35 @@ def create_sms( # # # @param [String] message_id Message ID. + # @param [String] content Email Content. # @param [Array] topics List of Topic IDs. # @param [Array] users List of User IDs. # @param [Array] targets List of Targets IDs. - # @param [String] content Email Content. # @param [] draft Is message a draft # @param [String] scheduled_at Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. # # @return [Message] def update_sms( message_id:, + content: nil, topics: nil, users: nil, targets: nil, - content: nil, 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 = { + content: content, topics: topics, users: users, targets: targets, - content: content, draft: draft, scheduledAt: scheduled_at, } @@ -478,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 = { @@ -510,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( @@ -544,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, @@ -626,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 @@ -636,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, @@ -684,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, @@ -716,6 +735,100 @@ def update_apns_provider( ) end + # Create a new Appwrite push provider. + # + # @param [String] provider_id Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # @param [String] name Provider name. + # @param [] enabled Set as enabled. + # @param [Integer] qos Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). + # + # @return [Provider] + def create_appwrite_provider( + provider_id:, + name:, + enabled: nil, + qos: nil, + expiry: nil + ) + if provider_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "providerId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + api_path = '/messaging/providers/appwrite' + + api_params = { + providerId: provider_id, + name: name, + enabled: enabled, + qos: qos, + expiry: expiry, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Provider + ) + end + + # Update an Appwrite push provider by its unique ID. + # + # @param [String] provider_id Provider ID. + # @param [String] name Provider name. + # @param [] enabled Set as enabled. + # @param [Integer] qos Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. + # @param [Integer] expiry Default message retention in seconds for offline delivery. Max 7 days (604800). + # + # @return [Provider] + def update_appwrite_provider( + provider_id:, + name: nil, + enabled: nil, + qos: nil, + expiry: nil + ) + if provider_id.nil? || provider_id == '' + raise Appwrite::Exception.new('Missing required parameter: "providerId"') + end + + api_path = '/messaging/providers/appwrite/{providerId}' + .gsub('{providerId}', provider_id) + + api_params = { + name: name, + enabled: enabled, + qos: qos, + expiry: expiry, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Provider + ) + end + # Create a new Firebase Cloud Messaging provider. # # @param [String] provider_id Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. @@ -730,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 @@ -740,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, @@ -776,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, @@ -830,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 @@ -840,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, @@ -894,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, @@ -946,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 @@ -956,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, @@ -998,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, @@ -1050,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 @@ -1060,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, @@ -1108,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, @@ -1162,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 @@ -1172,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, @@ -1220,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, @@ -1278,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 @@ -1288,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, @@ -1342,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, @@ -1410,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 @@ -1424,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, @@ -1490,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, @@ -1546,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 @@ -1556,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, @@ -1598,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, @@ -1646,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 @@ -1656,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, @@ -1698,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, @@ -1732,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. @@ -1746,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 @@ -1756,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, @@ -1787,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( @@ -1798,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, @@ -1846,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 @@ -1856,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, @@ -1898,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, @@ -1937,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 = { @@ -1968,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( @@ -2029,15 +2143,17 @@ def list_topics( # @param [String] topic_id Topic ID. Choose a custom Topic ID or a new Topic ID. # @param [String] name Topic Name. # @param [Array] subscribe An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + # @param [Integer] qos MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). # # @return [Topic] def create_topic( topic_id:, name:, - subscribe: nil + subscribe: nil, + qos: nil, + expiry: nil ) - api_path = '/messaging/topics' - if topic_id.nil? raise Appwrite::Exception.new('Missing required parameter: "topicId"') end @@ -2046,10 +2162,14 @@ def create_topic( raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/messaging/topics' + api_params = { topicId: topic_id, name: name, subscribe: subscribe, + qos: qos, + expiry: expiry, } api_headers = { @@ -2076,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 = { @@ -2105,23 +2225,29 @@ def get_topic( # @param [String] topic_id Topic ID. # @param [String] name Topic Name. # @param [Array] subscribe An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + # @param [Integer] qos MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. + # @param [Integer] expiry Message retention in seconds for offline delivery. Max 7 days (604800). # # @return [Topic] def update_topic( topic_id:, name: nil, - subscribe: nil + subscribe: nil, + qos: nil, + expiry: nil ) - api_path = '/messaging/topics/{topicId}' - .gsub('{topicId}', topic_id) - - 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, + qos: qos, + expiry: expiry, } api_headers = { @@ -2147,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( @@ -2183,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, @@ -2222,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 @@ -2237,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, @@ -2268,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 = { @@ -2306,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 0080fe00..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 = { @@ -303,6 +303,51 @@ def get_grant( ) end + # Introspect an OAuth2 access token or refresh token. Authenticate with an + # API key holding the `oauth2.introspect` scope to introspect any token in + # the project, or with the client credentials of the app the token was issued + # to. + # + # @param [String] token The access token or refresh token to introspect. + # @param [String] token_type_hint Type of token to introspect. Can be one of: `access_token` or `refresh_token`. + # @param [String] client_id OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. + # @param [String] client_secret OAuth2 client secret. + # + # @return [Oauth2Introspection] + def introspect( + token:, + token_type_hint: nil, + client_id: nil, + client_secret: nil + ) + if token.nil? + raise Appwrite::Exception.new('Missing required parameter: "token"') + end + + api_path = '/oauth2/{project_id}/introspect' + .gsub('{project_id}', @client.get_config('project')) + + api_params = { + token: token, + token_type_hint: token_type_hint, + client_id: client_id, + client_secret: client_secret, + } + + api_headers = { + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Oauth2Introspection + ) + end + # List the organizations the OAuth2 access token can access. Resolves the # token's `organization` authorization details, expanding the `*` wildcard # into the concrete set of organizations the user can see. @@ -353,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] @@ -372,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 @@ -387,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, @@ -464,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, } @@ -503,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, @@ -541,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] @@ -557,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 83c2817d..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,13 +237,13 @@ 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_path = '/organization/installations/{installationId}' + .gsub('{installationId}', installation_id) + api_params = {} api_headers = { @@ -259,20 +260,23 @@ def delete_installation( ) end - # Get a list of all API keys from the current organization. + # Get a list of all memberships 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 [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: userId, teamId, invited, joined, confirm, roles + # @param [String] search Search term to filter your list results. Max length: 256 chars. # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # - # @return [KeyList] - def list_keys( + # @return [MembershipList] + def list_memberships( queries: nil, + search: nil, total: nil ) - api_path = '/organization/keys' + api_path = '/organization/memberships' api_params = { queries: queries, + search: search, total: total, } @@ -286,43 +290,43 @@ def list_keys( path: api_path, headers: api_headers, params: api_params, - response_type: Models::KeyList + response_type: Models::MembershipList ) end - # Create a new organization API key. + # Invite a new member to join the current organization. An email with a link + # to join the organization will be sent to the new member's email address. If + # member doesn't exist in the project it will be automatically created. # - # @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. + # @param [Array] roles Array of strings. Use this param to set the user roles in the organization. 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. + # @param [String] email Email of the new organization member. + # @param [String] user_id ID of the user to be added to the organization. + # @param [String] phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + # @param [String] url URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. + # @param [String] name Name of the new organization member. Max length: 128 chars. # - # @return [Key] - def create_key( - key_id:, - name:, - scopes:, - expire: nil + # @return [Membership] + def create_membership( + roles:, + email: nil, + user_id: nil, + phone: nil, + url: nil, + name: 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"') + if roles.nil? + raise Appwrite::Exception.new('Missing required parameter: "roles"') end - if scopes.nil? - raise Appwrite::Exception.new('Missing required parameter: "scopes"') - end + api_path = '/organization/memberships' api_params = { - keyId: key_id, + email: email, + userId: user_id, + phone: phone, + roles: roles, + url: url, name: name, - scopes: scopes, - expire: expire, } api_headers = { @@ -336,26 +340,25 @@ def create_key( path: api_path, headers: api_headers, params: api_params, - response_type: Models::Key + response_type: Models::Membership ) end - # Get a key by its unique ID. This endpoint returns details about a specific - # API key in your organization including its scopes. + # Get a membership from the current organization by its unique ID. # - # @param [String] key_id Key unique ID. + # @param [String] membership_id Membership ID. # - # @return [Key] - def get_key( - key_id: + # @return [Membership] + def get_membership( + membership_id: ) - api_path = '/organization/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') + 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 = { @@ -368,44 +371,33 @@ def get_key( path: api_path, headers: api_headers, params: api_params, - response_type: Models::Key + response_type: Models::Membership ) end - # Update a key by its unique ID. Use this endpoint to update the name, - # scopes, or expiration time of an API key. + # Modify the roles of a member in the current organization. # - # @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. + # @param [String] membership_id Membership ID. + # @param [Array] roles An array of strings. Use this param to set the user's roles in the organization. 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 [Key] - def update_key( - key_id:, - name:, - scopes:, - expire: nil + # @return [Membership] + def update_membership( + membership_id:, + roles: ) - api_path = '/organization/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') + if membership_id.nil? || membership_id == '' + raise Appwrite::Exception.new('Missing required parameter: "membershipId"') end - if name.nil? - raise Appwrite::Exception.new('Missing required parameter: "name"') + if roles.nil? + raise Appwrite::Exception.new('Missing required parameter: "roles"') end - if scopes.nil? - raise Appwrite::Exception.new('Missing required parameter: "scopes"') - end + api_path = '/organization/memberships/{membershipId}' + .gsub('{membershipId}', membership_id) api_params = { - name: name, - scopes: scopes, - expire: expire, + roles: roles, } api_headers = { @@ -415,35 +407,37 @@ def update_key( } @client.call( - method: 'PUT', + method: 'PATCH', path: api_path, headers: api_headers, params: api_params, - response_type: Models::Key + response_type: Models::Membership ) end - # Delete a key by its unique ID. Once deleted, the key can no longer be used - # to authenticate API calls. + # Remove a member from the current organization. The member is removed + # whether they accepted the invitation or not; a pending invitation is + # revoked. # - # @param [String] key_id Key unique ID. + # @param [String] membership_id Membership ID. # # @return [] - def delete_key( - key_id: + def delete_membership( + membership_id: ) - api_path = '/organization/keys/{keyId}' - .gsub('{keyId}', key_id) - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') + 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( @@ -454,19 +448,20 @@ def delete_key( ) end - # Get a list of all memberships from the current organization. + # Get a list of all projects. 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: userId, teamId, invited, joined, confirm, roles + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search, accessedAt # @param [String] search Search term to filter your list results. Max length: 256 chars. # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # - # @return [MembershipList] - def list_memberships( + # @return [ProjectList] + def list_projects( queries: nil, search: nil, total: nil ) - api_path = '/organization/memberships' + api_path = '/organization/projects' api_params = { queries: queries, @@ -484,43 +479,36 @@ def list_memberships( path: api_path, headers: api_headers, params: api_params, - response_type: Models::MembershipList + response_type: Models::ProjectList ) end - # Invite a new member to join the current organization. An email with a link - # to join the organization will be sent to the new member's email address. If - # member doesn't exist in the project it will be automatically created. + # Create a new project. # - # @param [Array] roles Array of strings. Use this param to set the user roles in the organization. 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. - # @param [String] email Email of the new organization member. - # @param [String] user_id ID of the user to be added to the organization. - # @param [String] phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. - # @param [String] url URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. - # @param [String] name Name of the new organization member. Max length: 128 chars. + # @param [String] project_id Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. + # @param [String] name Project name. Max length: 128 chars. + # @param [Region] region Project Region. # - # @return [Membership] - def create_membership( - roles:, - email: nil, - user_id: nil, - phone: nil, - url: nil, - name: nil + # @return [Project] + def create_project( + project_id:, + name:, + region: nil ) - api_path = '/organization/memberships' + if project_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "projectId"') + end - if roles.nil? - raise Appwrite::Exception.new('Missing required parameter: "roles"') + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/organization/projects' + api_params = { - email: email, - userId: user_id, - phone: phone, - roles: roles, - url: url, + projectId: project_id, name: name, + region: region, } api_headers = { @@ -534,25 +522,25 @@ def create_membership( path: api_path, headers: api_headers, params: api_params, - response_type: Models::Membership + response_type: Models::Project ) end - # Get a membership from the current organization by its unique ID. + # Get a project. # - # @param [String] membership_id Membership ID. + # @param [String] project_id Project unique ID. # - # @return [Membership] - def get_membership( - membership_id: + # @return [Project] + def get_project( + project_id: ) - api_path = '/organization/memberships/{membershipId}' - .gsub('{membershipId}', membership_id) - - if membership_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "membershipId"') + 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 = { @@ -565,33 +553,33 @@ def get_membership( path: api_path, headers: api_headers, params: api_params, - response_type: Models::Membership + response_type: Models::Project ) end - # Modify the roles of a member in the current organization. + # Update a project by its unique ID. # - # @param [String] membership_id Membership ID. - # @param [Array] roles An array of strings. Use this param to set the user's roles in the organization. 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. + # @param [String] project_id Project unique ID. + # @param [String] name Project name. Max length: 128 chars. # - # @return [Membership] - def update_membership( - membership_id:, - roles: + # @return [Project] + def update_project( + project_id:, + name: ) - api_path = '/organization/memberships/{membershipId}' - .gsub('{membershipId}', membership_id) - - if membership_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "membershipId"') + if project_id.nil? || project_id == '' + raise Appwrite::Exception.new('Missing required parameter: "projectId"') end - if roles.nil? - raise Appwrite::Exception.new('Missing required parameter: "roles"') + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/organization/projects/{projectId}' + .gsub('{projectId}', project_id) + api_params = { - roles: roles, + name: name, } api_headers = { @@ -605,32 +593,31 @@ def update_membership( path: api_path, headers: api_headers, params: api_params, - response_type: Models::Membership + response_type: Models::Project ) end - # Remove a member from the current organization. The member is removed - # whether they accepted the invitation or not; a pending invitation is - # revoked. + # Delete a project by its unique ID. # - # @param [String] membership_id Membership ID. + # @param [String] project_id Project unique ID. # # @return [] - def delete_membership( - membership_id: + def delete_project( + project_id: ) - api_path = '/organization/memberships/{membershipId}' - .gsub('{membershipId}', membership_id) - - if membership_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "membershipId"') + 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( @@ -641,24 +628,27 @@ def delete_membership( ) end - # Get a list of all projects. You can use the query params to filter your - # results. + # Get a list of all API keys of a project in your 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: name, teamId, labels, search, accessedAt - # @param [String] search Search term to filter your list results. Max length: 256 chars. + # @param [String] project_id Project unique ID. + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire, accessedAt, name, scopes # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # - # @return [ProjectList] - def list_projects( + # @return [KeyList] + def list_project_keys( + project_id:, queries: nil, - search: nil, total: nil ) - api_path = '/organization/projects' + if project_id.nil? || project_id == '' + raise Appwrite::Exception.new('Missing required parameter: "projectId"') + end + + api_path = '/organization/projects/{projectId}/keys' + .gsub('{projectId}', project_id) api_params = { queries: queries, - search: search, total: total, } @@ -672,36 +662,45 @@ def list_projects( path: api_path, headers: api_headers, params: api_params, - response_type: Models::ProjectList + response_type: Models::KeyList ) end - # Create a new project. + # Create a new ephemeral API key for a project in your organization. It's + # recommended to have multiple API keys with strict scopes for separate + # functions within your project. # - # @param [String] project_id Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. - # @param [String] name Project name. Max length: 128 chars. - # @param [Region] region Project Region. + # You can also create a standard API key if you need a longer-lived key + # instead. # - # @return [Project] - def create_project( + # @param [String] project_id Project unique ID. + # @param [Array] scopes Key scopes list. Maximum of 200 scopes are allowed. + # @param [Integer] duration Time in seconds before ephemeral key expires. Maximum duration is 3600 seconds. + # + # @return [EphemeralKey] + def create_ephemeral_project_key( project_id:, - name:, - region: nil + scopes:, + duration: ) - api_path = '/organization/projects' - - if project_id.nil? + if project_id.nil? || project_id == '' raise Appwrite::Exception.new('Missing required parameter: "projectId"') end - if name.nil? - raise Appwrite::Exception.new('Missing required parameter: "name"') + if scopes.nil? + raise Appwrite::Exception.new('Missing required parameter: "scopes"') + end + + if duration.nil? + raise Appwrite::Exception.new('Missing required parameter: "duration"') end + api_path = '/organization/projects/{projectId}/keys/ephemeral' + .gsub('{projectId}', project_id) + api_params = { - projectId: project_id, - name: name, - region: region, + scopes: scopes, + duration: duration, } api_headers = { @@ -715,29 +714,37 @@ def create_project( path: api_path, headers: api_headers, params: api_params, - response_type: Models::Project + response_type: Models::EphemeralKey ) end - # Get a project. + # Get a project key by its unique ID. # # @param [String] project_id Project unique ID. + # @param [String] key_id Key ID. # - # @return [Project] - def get_project( - project_id: + # @return [Key] + def get_project_key( + project_id:, + key_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 + if key_id.nil? || key_id == '' + raise Appwrite::Exception.new('Missing required parameter: "keyId"') + end + + api_path = '/organization/projects/{projectId}/keys/{keyId}' + .gsub('{projectId}', project_id) + .gsub('{keyId}', key_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', } @client.call( @@ -745,33 +752,51 @@ def get_project( path: api_path, headers: api_headers, params: api_params, - response_type: Models::Project + response_type: Models::Key ) end - # Update a project by its unique ID. + # Update a project key by its unique ID. Use this endpoint to update the + # name, scopes, or expiration time of an API key. # # @param [String] project_id Project unique ID. - # @param [String] name Project name. Max length: 128 chars. + # @param [String] key_id Key ID. + # @param [String] name Key name. Max length: 128 chars. + # @param [Array] scopes Key scopes list. Maximum of 200 scopes are allowed. + # @param [String] expire Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. # - # @return [Project] - def update_project( + # @return [Key] + def update_project_key( project_id:, - name: + key_id:, + name:, + scopes:, + expire: nil ) - 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 + if key_id.nil? || key_id == '' + raise Appwrite::Exception.new('Missing required parameter: "keyId"') + end + if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end + if scopes.nil? + raise Appwrite::Exception.new('Missing required parameter: "scopes"') + end + + api_path = '/organization/projects/{projectId}/keys/{keyId}' + .gsub('{projectId}', project_id) + .gsub('{keyId}', key_id) + api_params = { name: name, + scopes: scopes, + expire: expire, } api_headers = { @@ -781,34 +806,43 @@ def update_project( } @client.call( - method: 'PATCH', + method: 'PUT', path: api_path, headers: api_headers, params: api_params, - response_type: Models::Project + response_type: Models::Key ) end - # Delete a project by its unique ID. + # Delete a project key by its unique ID. Once deleted, the key can no longer + # be used to authenticate API calls. # # @param [String] project_id Project unique ID. + # @param [String] key_id Key ID. # # @return [] - def delete_project( - project_id: + def delete_project_key( + project_id:, + key_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 + if key_id.nil? || key_id == '' + raise Appwrite::Exception.new('Missing required parameter: "keyId"') + end + + api_path = '/organization/projects/{projectId}/keys/{keyId}' + .gsub('{projectId}', project_id) + .gsub('{keyId}', key_id) + api_params = {} api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( 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 6235af24..3af66499 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, } @@ -136,8 +138,6 @@ def create_ephemeral_key( scopes:, duration: ) - api_path = '/project/keys/ephemeral' - if scopes.nil? raise Appwrite::Exception.new('Missing required parameter: "scopes"') end @@ -146,6 +146,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, @@ -174,13 +176,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 = { @@ -212,10 +214,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 @@ -227,6 +226,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, @@ -257,18 +259,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( @@ -288,12 +291,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, } @@ -356,8 +359,6 @@ def create_mock_phone( number:, otp: ) - api_path = '/project/mock-phones' - if number.nil? raise Appwrite::Exception.new('Missing required parameter: "number"') end @@ -366,6 +367,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, @@ -395,13 +398,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 = { @@ -429,10 +432,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 @@ -440,6 +440,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, } @@ -468,18 +471,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( @@ -561,8 +565,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 @@ -571,6 +573,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, @@ -646,7 +650,9 @@ def update_o_auth2_amazon( # @param [String] key_id 'Key ID' of Apple OAuth2 app. For example: P4000000N8 # @param [String] team_id 'Team ID' of Apple OAuth2 app. For example: D4000000R6 # @param [String] p8_file Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- - # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # @param [Array] native_client_ids App bundle IDs accepted as ID token audiences for native Sign in with Apple. For example: com.example.app. Together with the Services ID, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + # @param [] enabled Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + # @param [] native_enabled Native Sign in with Apple status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a Services ID or at least one native client ID to match tokens against, but no key or team ID: this method verifies a signature rather than redeeming an authorization code. # # @return [OAuth2Apple] def update_o_auth2_apple( @@ -654,7 +660,9 @@ def update_o_auth2_apple( key_id: nil, team_id: nil, p8_file: nil, - enabled: nil + native_client_ids: nil, + enabled: nil, + native_enabled: nil ) api_path = '/project/oauth2/apple' @@ -663,7 +671,9 @@ def update_o_auth2_apple( keyId: key_id, teamId: team_id, p8File: p8_file, + nativeClientIds: native_client_ids, enabled: enabled, + nativeEnabled: native_enabled, } api_headers = { @@ -721,6 +731,7 @@ def update_o_auth2_appwrite( # @param [String] client_id 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq # @param [String] client_secret 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF # @param [String] endpoint Domain of Auth0 instance. For example: example.us.auth0.com + # @param [Array] prompt Array of Auth0 OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Auth0 default. # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. # # @return [OAuth2Auth0] @@ -728,6 +739,7 @@ def update_o_auth2_auth0( client_id: nil, client_secret: nil, endpoint: nil, + prompt: nil, enabled: nil ) api_path = '/project/oauth2/auth0' @@ -736,6 +748,7 @@ def update_o_auth2_auth0( clientId: client_id, clientSecret: client_secret, endpoint: endpoint, + prompt: prompt, enabled: enabled, } @@ -1006,12 +1019,14 @@ def update_o_auth2_dailymotion( # # @param [String] client_id 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 # @param [String] client_secret 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + # @param [Array] prompt Array with at most one Discord OAuth2 prompt value. "none" means: skip the authorization screen for users who already authorized the app with the requested scopes. "consent" means: ask users who already authorized the app to approve it again. Pass an empty array to use the Discord default. # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. # # @return [OAuth2Discord] def update_o_auth2_discord( client_id: nil, client_secret: nil, + prompt: nil, enabled: nil ) api_path = '/project/oauth2/discord' @@ -1019,6 +1034,7 @@ def update_o_auth2_discord( api_params = { clientId: client_id, clientSecret: client_secret, + prompt: prompt, enabled: enabled, } @@ -1254,12 +1270,14 @@ def update_o_auth2_fusion_auth( # # @param [String] client_id 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 # @param [String] client_secret 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + # @param [Array] prompt Array of GitHub OAuth2 prompt values. "select_account" means: prompt the user to select an account. Pass an empty array to use the GitHub default. # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. # # @return [OAuth2Github] def update_o_auth2_git_hub( client_id: nil, client_secret: nil, + prompt: nil, enabled: nil ) api_path = '/project/oauth2/github' @@ -1267,6 +1285,7 @@ def update_o_auth2_git_hub( api_params = { clientId: client_id, clientSecret: client_secret, + prompt: prompt, enabled: enabled, } @@ -1328,14 +1347,18 @@ def update_o_auth2_gitlab( # @param [String] client_id 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com # @param [String] client_secret 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj # @param [Array] prompt Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. - # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # @param [Array] native_client_ids Additional OAuth2 client IDs accepted as ID token audiences for native sign-in (Android and iOS client IDs). Together with the client ID, which is always accepted, these are the only client IDs whose tokens are trusted. Pass an empty array to clear the list. + # @param [] enabled Browser-based OAuth2 sign-in status. Set to true to enable new session creation through the redirect flow. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. Has no effect on native sign-in, which is controlled by nativeEnabled only. + # @param [] native_enabled Native Google sign-in status. This is the only switch for creating sessions from ID tokens obtained on device and is independent of enabled. Needs a client ID or at least one native client ID to match tokens against, but no client secret: this method verifies a signature rather than redeeming an authorization code. # # @return [OAuth2Google] def update_o_auth2_google( client_id: nil, client_secret: nil, prompt: nil, - enabled: nil + native_client_ids: nil, + enabled: nil, + native_enabled: nil ) api_path = '/project/oauth2/google' @@ -1343,7 +1366,9 @@ def update_o_auth2_google( clientId: client_id, clientSecret: client_secret, prompt: prompt, + nativeClientIds: native_client_ids, enabled: enabled, + nativeEnabled: native_enabled, } api_headers = { @@ -1396,6 +1421,44 @@ def update_o_auth2_hugging_face( ) end + # Update the project OAuth2 Kakao configuration. + # + # @param [String] client_id 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de + # @param [String] client_secret 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled + # @param [Array] prompt Array of Kakao OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. + # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # + # @return [OAuth2Kakao] + def update_o_auth2_kakao( + client_id: nil, + client_secret: nil, + prompt: nil, + enabled: nil + ) + api_path = '/project/oauth2/kakao' + + api_params = { + clientId: client_id, + clientSecret: client_secret, + prompt: prompt, + enabled: enabled, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::OAuth2Kakao + ) + end + # Update the project OAuth2 Keycloak configuration. # # @param [String] client_id 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app @@ -1512,6 +1575,7 @@ def update_o_auth2_linkedin( # @param [String] application_id 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 # @param [String] application_secret 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u # @param [String] tenant Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + # @param [Array] prompt Array of Microsoft OAuth2 prompt values. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. Pass an empty array to use the Microsoft default. # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. # # @return [OAuth2Microsoft] @@ -1519,6 +1583,7 @@ def update_o_auth2_microsoft( application_id: nil, application_secret: nil, tenant: nil, + prompt: nil, enabled: nil ) api_path = '/project/oauth2/microsoft' @@ -1527,6 +1592,7 @@ def update_o_auth2_microsoft( applicationId: application_id, applicationSecret: application_secret, tenant: tenant, + prompt: prompt, enabled: enabled, } @@ -1639,6 +1705,7 @@ def update_o_auth2_oidc( # @param [String] client_secret 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV # @param [String] domain Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ # @param [String] authorization_server_id Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + # @param [Array] prompt Array of Okta OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Okta default. # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. # # @return [OAuth2Okta] @@ -1647,6 +1714,7 @@ def update_o_auth2_okta( client_secret: nil, domain: nil, authorization_server_id: nil, + prompt: nil, enabled: nil ) api_path = '/project/oauth2/okta' @@ -1656,6 +1724,7 @@ def update_o_auth2_okta( clientSecret: client_secret, domain: domain, authorizationServerId: authorization_server_id, + prompt: prompt, enabled: enabled, } @@ -1818,12 +1887,14 @@ def update_o_auth2_resend( # # @param [String] customer_key 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq # @param [String] customer_secret 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + # @param [Array] prompt Array of Salesforce OAuth2 prompt values. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. Pass an empty array to use the Salesforce default. # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. # # @return [OAuth2Salesforce] def update_o_auth2_salesforce( customer_key: nil, customer_secret: nil, + prompt: nil, enabled: nil ) api_path = '/project/oauth2/salesforce' @@ -1831,6 +1902,7 @@ def update_o_auth2_salesforce( api_params = { customerKey: customer_key, customerSecret: customer_secret, + prompt: prompt, enabled: enabled, } @@ -1954,6 +2026,41 @@ def update_o_auth2_stripe( ) end + # Update the project OAuth2 TikTok configuration. + # + # @param [String] client_id 'Client key' of TikTok OAuth2 app. For example: awz000000000tyw0 + # @param [String] client_secret 'Client secret' of TikTok OAuth2 app. For example: 6wXewM00000000000000000000yXnite + # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # + # @return [OAuth2TikTok] + def update_o_auth2_tik_tok( + client_id: nil, + client_secret: nil, + enabled: nil + ) + api_path = '/project/oauth2/tiktok' + + api_params = { + clientId: client_id, + clientSecret: client_secret, + enabled: enabled, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::OAuth2TikTok + ) + end + # Update the project OAuth2 Tradeshift configuration. # # @param [String] oauth2_client_id 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app @@ -2059,6 +2166,41 @@ def update_o_auth2_twitch( ) end + # Update the project OAuth2 Webflow configuration. + # + # @param [String] client_id 'Client ID' of Webflow OAuth2 app. For example: 8bb20000000000000000000000000000000000000000000000000000000040dd + # @param [String] client_secret 'Client Secret' of Webflow OAuth2 app. For example: 59bf00000000000000000000000000000000000000000000000000000000fe59 + # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + # + # @return [OAuth2Webflow] + def update_o_auth2_webflow( + client_id: nil, + client_secret: nil, + enabled: nil + ) + api_path = '/project/oauth2/webflow' + + api_params = { + clientId: client_id, + clientSecret: client_secret, + enabled: enabled, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::OAuth2Webflow + ) + end + # Update the project OAuth2 WordPress configuration. # # @param [String] client_id 'Client ID' of WordPress OAuth2 app. For example: 130005 @@ -2203,12 +2345,14 @@ def update_o_auth2_yandex( # # @param [String] client_id 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B # @param [String] client_secret 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + # @param [Array] prompt Array of Zoho OAuth2 prompt values. "consent" means: prompt the user for consent. Pass an empty array to use the Zoho default. # @param [] enabled OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. # # @return [OAuth2Zoho] def update_o_auth2_zoho( client_id: nil, client_secret: nil, + prompt: nil, enabled: nil ) api_path = '/project/oauth2/zoho' @@ -2216,6 +2360,7 @@ def update_o_auth2_zoho( api_params = { clientId: client_id, clientSecret: client_secret, + prompt: prompt, enabled: enabled, } @@ -2274,17 +2419,17 @@ def update_o_auth2_zoom( # # @param [ProjectOAuthProviderId] provider_id OAuth2 provider key. For example: github, google, apple. # - # @return [OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2HuggingFace, OAuth2Resend, OAuth2Cloudflare, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft] + # @return [OAuth2Github, OAuth2Discord, OAuth2Figma, OAuth2Dropbox, OAuth2Dailymotion, OAuth2Bitbucket, OAuth2Bitly, OAuth2Box, OAuth2Autodesk, OAuth2Google, OAuth2Zoom, OAuth2Zoho, OAuth2Yandex, OAuth2X, OAuth2WordPress, OAuth2Webflow, OAuth2Twitch, OAuth2Stripe, OAuth2Spotify, OAuth2Slack, OAuth2Podio, OAuth2Notion, OAuth2Salesforce, OAuth2Yahoo, OAuth2HuggingFace, OAuth2Resend, OAuth2Cloudflare, OAuth2Linkedin, OAuth2Disqus, OAuth2Amazon, OAuth2Etsy, OAuth2Facebook, OAuth2Tradeshift, OAuth2Paypal, OAuth2Gitlab, OAuth2Authentik, OAuth2Auth0, OAuth2FusionAuth, OAuth2Keycloak, OAuth2Oidc, OAuth2Apple, OAuth2Okta, OAuth2Kick, OAuth2Microsoft, OAuth2TikTok, OAuth2Kakao] def get_o_auth2_provider( provider_id: ) - 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 = { @@ -2378,6 +2523,11 @@ def get_o_auth2_provider( return Models::OAuth2WordPress.from(map: response) end + if response['$id'] == 'webflow' + + return Models::OAuth2Webflow.from(map: response) + end + if response['$id'] == 'twitch' return Models::OAuth2Twitch.from(map: response) @@ -2518,6 +2668,16 @@ def get_o_auth2_provider( return Models::OAuth2Microsoft.from(map: response) end + if response['$id'] == 'tiktok' + + return Models::OAuth2TikTok.from(map: response) + end + + if response['$id'] == 'kakao' + + return Models::OAuth2Kakao.from(map: response) + end + raise Exception, "Unable to match response to any expected response model" end @@ -2560,15 +2720,15 @@ def list_platforms( # @param [String] platform_id Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. # @param [String] name Platform name. Max length: 128 chars. # @param [String] application_id Android application ID. Max length: 256 chars. + # @param [Array] fingerprints SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. # # @return [PlatformAndroid] def create_android_platform( platform_id:, name:, - application_id: + application_id:, + fingerprints: nil ) - api_path = '/project/platforms/android' - if platform_id.nil? raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -2581,10 +2741,13 @@ 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, applicationId: application_id, + fingerprints: fingerprints, } api_headers = { @@ -2603,22 +2766,21 @@ 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. # @param [String] application_id Android application ID. Max length: 256 chars. + # @param [Array] fingerprints SHA-256 fingerprints of the certificates your app is signed with, such as "14:6D:E9:...:2B:6A". Passkeys created in the app are accepted when its signature matches one. Find them under App signing in Play Console, or with `./gradlew signingReport`. Omit to keep the current list, or pass an empty array to clear it. # # @return [PlatformAndroid] def update_android_platform( platform_id:, name:, - application_id: + application_id:, + fingerprints: nil ) - api_path = '/project/platforms/android/{platformId}' - .gsub('{platformId}', platform_id) - - if platform_id.nil? + if platform_id.nil? || platform_id == '' raise Appwrite::Exception.new('Missing required parameter: "platformId"') end @@ -2630,9 +2792,13 @@ 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, + fingerprints: fingerprints, } api_headers = { @@ -2664,8 +2830,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 @@ -2678,6 +2842,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, @@ -2712,10 +2878,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 @@ -2727,6 +2890,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, @@ -2761,8 +2927,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 @@ -2775,6 +2939,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, @@ -2809,10 +2975,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 @@ -2824,6 +2987,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, @@ -2858,8 +3024,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 @@ -2872,6 +3036,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, @@ -2906,10 +3072,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 @@ -2921,6 +3084,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, @@ -2955,8 +3121,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 @@ -2969,6 +3133,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, @@ -3003,10 +3169,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 @@ -3018,6 +3181,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, @@ -3047,13 +3213,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 = { @@ -3109,18 +3275,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( @@ -3171,12 +3338,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, } @@ -3205,12 +3372,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, } @@ -3239,12 +3406,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, } @@ -3273,12 +3440,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, } @@ -3386,6 +3553,44 @@ def update_mfa_factors_policy( ) end + # Set the relying party ID passkeys are bound to: the domain of your + # application. Passkeys work on the project's web platforms on that domain or + # its subdomains, and on the domain itself for Apple apps. A localhost web + # platform enables passkeys for local development without a relying party ID. + # The relying party ID cannot change while users have passkeys, and any + # change invalidates ceremonies in progress. + # + # @param [String] rp_id Relying party ID: the domain of your application, such as `example.com`. Use `localhost` for local development, or an empty string to unset it. + # + # @return [Project] + def update_passkey_policy( + rp_id: + ) + if rp_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "rpId"') + end + + api_path = '/project/policies/passkey' + + api_params = { + rpId: rp_id, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Project + ) + end + # Updating this policy allows you to control if new passwords are checked # against most common passwords dictionary. When enabled, and user changes # their password, password must not be contained in the dictionary. @@ -3396,12 +3601,12 @@ def update_mfa_factors_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, } @@ -3437,12 +3642,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, } @@ -3473,14 +3678,90 @@ 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, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Project + ) + end + + # Updating this policy allows you to control if passwords are checked against + # the Have I Been Pwned breach database. When enabled, every password a user + # signs up, signs in or resets with is checked and the result is recorded on + # the user as `passwordPwned`. On its own the policy only records. Enable + # `users` to reject a breached password when a user signs up or sets a new + # password, and `sessions` to refuse a sign-in with a breached password until + # it is reset. Only the first five characters of the password hash are ever + # shared with the service. Options left out keep their current value. + # + # @param [] enabled Toggle password pwned policy. Set to true to check passwords against known data breaches and record the result on the user, or false to never check. Default is true. On its own this only records; use `users` and `sessions` to block. When changing this policy, existing passwords remain valid. + # @param [] sessions Whether a sign-in with a breached password is refused until the password is reset. Default is false, which allows the sign-in and only records the result. + # @param [] users Whether a breached password is rejected when a user signs up or sets a new password. Default is false, which allows the password and only records the result. + # + # @return [Project] + def update_password_pwned_policy( + enabled: nil, + sessions: nil, + users: nil + ) + api_path = '/project/policies/password-pwned' + + api_params = { + enabled: enabled, + sessions: sessions, + users: users, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Project + ) + end + + # Require a password reset when an email/password sign-in uses a password + # older than the configured maximum age. Options left out keep their current + # value. + # + # @param [] enabled Enable password rotation. Disabled by default. + # @param [Integer] max_age Maximum password age in seconds. Minimum allowed value is 86400 seconds (1 day), and maximum is 10 years, which is 315360000 seconds. Defaults to 1 year, which is 31536000 seconds. + # + # @return [Project] + def update_password_rotation_policy( + enabled: nil, + max_age: nil + ) + api_path = '/project/policies/password-rotation' + api_params = { enabled: enabled, + maxAge: max_age, } api_headers = { @@ -3551,12 +3832,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, } @@ -3585,12 +3866,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, } @@ -3620,12 +3901,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, } @@ -3654,12 +3935,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, } @@ -3689,12 +3970,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, } @@ -3717,19 +3998,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, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy, PolicyMfaFactors, PolicyDenyAliasedEmail, PolicyDenyDisposableEmail, PolicyDenyFreeEmail, PolicyDenyCorporateEmail] + # @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 = { @@ -3768,6 +4049,16 @@ def get_policy( return Models::PolicyPasswordPersonalData.from(map: response) end + if response['$id'] == 'password-pwned' + + return Models::PolicyPasswordPwned.from(map: response) + end + + if response['$id'] == 'password-rotation' + + return Models::PolicyPasswordRotation.from(map: response) + end + if response['$id'] == 'session-alert' return Models::PolicySessionAlert.from(map: response) @@ -3823,6 +4114,11 @@ def get_policy( return Models::PolicyDenyCorporateEmail.from(map: response) end + if response['$id'] == 'passkey' + + return Models::PolicyPasskey.from(map: response) + end + raise Exception, "Unable to match response to any expected response model" end @@ -3837,9 +4133,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 @@ -3848,6 +4141,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, } @@ -3878,9 +4174,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 @@ -3889,6 +4182,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, } @@ -3974,12 +4270,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, } @@ -3987,6 +4283,7 @@ def create_smtp_test( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -4033,7 +4330,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. @@ -4053,12 +4350,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, @@ -4089,7 +4386,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] @@ -4097,13 +4394,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, } @@ -4168,8 +4465,6 @@ def create_variable( value:, secret: nil ) - api_path = '/project/variables' - if variable_id.nil? raise Appwrite::Exception.new('Missing required parameter: "variableId"') end @@ -4182,6 +4477,8 @@ def create_variable( raise Appwrite::Exception.new('Missing required parameter: "value"') end + api_path = '/project/variables' + api_params = { variableId: variable_id, key: key, @@ -4212,13 +4509,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 = { @@ -4249,13 +4546,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, @@ -4285,18 +4582,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 8c191805..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, @@ -158,12 +158,17 @@ def create( # Get a list of all frameworks that are currently available on the server # instance. # + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [FrameworkList] - def list_frameworks() + def list_frameworks( + total: nil + ) api_path = '/sites/frameworks' - api_params = {} + api_params = { + total: total, + } api_headers = { "X-Appwrite-Project": @client.get_config('project'), @@ -182,15 +187,18 @@ def list_frameworks() # List allowed site specifications for this instance. # # @param [String] type Specification type to list. Can be one of: runtimes, builds. Defaults to runtimes. + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [SpecificationList] def list_specifications( - type: nil + type: nil, + total: nil ) api_path = '/sites/specifications' api_params = { type: type, + total: total, } api_headers = { @@ -215,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 = { @@ -292,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 @@ -307,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, @@ -356,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( @@ -389,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 @@ -400,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, } @@ -434,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, @@ -482,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 @@ -493,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, @@ -517,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 @@ -535,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 @@ -546,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, } @@ -589,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 @@ -616,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, @@ -656,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 @@ -671,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, @@ -702,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 = { @@ -740,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( @@ -783,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, @@ -827,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 = { @@ -869,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, @@ -905,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 = { @@ -943,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 = { @@ -983,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, @@ -1026,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 @@ -1045,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, @@ -1077,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 = { @@ -1121,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, @@ -1164,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 c1ee72b5..6c408ff8 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] @@ -122,15 +122,18 @@ def list_specifications() # List transactions across all databases. # # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [TransactionList] def list_transactions( - queries: nil + queries: nil, + total: nil ) api_path = '/tablesdb/transactions' api_params = { queries: queries, + total: total, } api_headers = { @@ -184,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 = { @@ -219,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, @@ -254,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( @@ -286,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, } @@ -321,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 = { @@ -362,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, @@ -401,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( @@ -441,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, } @@ -476,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 = { @@ -513,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 @@ -524,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, @@ -554,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 = { @@ -593,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 = { @@ -636,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 = { @@ -682,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, @@ -718,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 = { @@ -751,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 = { @@ -789,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, @@ -841,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 @@ -856,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, @@ -892,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 = { @@ -940,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, @@ -986,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( @@ -1027,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, @@ -1082,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 @@ -1102,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, @@ -1150,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 @@ -1175,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, @@ -1217,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 @@ -1237,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, @@ -1278,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 @@ -1303,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, @@ -1342,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 @@ -1362,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, @@ -1403,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 @@ -1428,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, @@ -1468,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 @@ -1488,8 +1490,12 @@ def create_email_column( raise Appwrite::Exception.new('Missing required parameter: "required"') end - api_params = { - key: key, + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/email' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + + api_params = { + key: key, required: required, default: default, array: array, @@ -1530,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 @@ -1555,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, @@ -1597,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 @@ -1621,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, @@ -1666,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 @@ -1695,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, @@ -1741,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 @@ -1761,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, @@ -1809,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 @@ -1834,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, @@ -1881,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 @@ -1901,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, @@ -1949,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 @@ -1974,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, @@ -2016,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 @@ -2036,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, @@ -2078,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 @@ -2103,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, @@ -2140,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 @@ -2160,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, @@ -2200,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 @@ -2221,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, @@ -2263,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 @@ -2283,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, @@ -2326,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 @@ -2351,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, @@ -2393,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 @@ -2413,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, @@ -2456,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 @@ -2481,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, @@ -2518,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 @@ -2538,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, @@ -2578,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 @@ -2599,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, @@ -2636,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 @@ -2656,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, @@ -2696,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 @@ -2717,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, @@ -2762,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 @@ -2782,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, @@ -2806,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:, + on_delete: nil, + new_key: nil + ) + 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) + + 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 ) - api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/string' - .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 @@ -2856,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, @@ -2905,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 @@ -2930,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, @@ -2973,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 @@ -2993,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, @@ -3036,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 @@ -3061,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, @@ -3101,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 @@ -3121,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, @@ -3163,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 @@ -3188,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, @@ -3232,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 @@ -3256,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, @@ -3302,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 @@ -3327,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, @@ -3355,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 = { @@ -3421,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) @@ -3441,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) @@ -3461,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'), @@ -3540,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 @@ -3562,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, @@ -3615,15 +3662,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 @@ -3639,6 +3682,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, @@ -3674,23 +3721,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 = { @@ -3719,28 +3766,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( @@ -3770,18 +3818,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, @@ -3824,15 +3872,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 @@ -3844,6 +3888,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, @@ -3883,15 +3931,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 @@ -3899,6 +3943,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, @@ -3937,15 +3985,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 @@ -3953,6 +3997,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, @@ -3990,18 +4038,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, @@ -4038,18 +4086,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, @@ -4087,23 +4135,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, @@ -4144,23 +4192,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, @@ -4201,23 +4249,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, @@ -4253,23 +4301,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, } @@ -4277,6 +4325,7 @@ def delete_row( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -4307,28 +4356,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, @@ -4370,28 +4419,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 d6325633..2ea9909f 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, @@ -464,6 +465,7 @@ def list_memberships( # # @param [String] team_id Team ID. # @param [Array] roles Array of strings. Use this param to set the user roles in the team. 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. + # @param [String] membership_id Membership ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. # @param [String] email Email of the new team member. # @param [String] user_id ID of the user to be added to a team. # @param [String] phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. @@ -474,16 +476,14 @@ def list_memberships( def create_membership( team_id:, roles:, + membership_id: nil, email: nil, user_id: nil, phone: nil, url: nil, name: 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 @@ -491,7 +491,11 @@ def create_membership( raise Appwrite::Exception.new('Missing required parameter: "roles"') end + api_path = '/teams/{teamId}/memberships' + .gsub('{teamId}', team_id) + api_params = { + membershipId: membership_id, email: email, userId: user_id, phone: phone, @@ -527,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 = { @@ -570,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 @@ -586,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, } @@ -617,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( @@ -664,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 @@ -684,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, @@ -714,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 = { @@ -749,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 @@ -760,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 86f54836..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,17 +1126,140 @@ def update_name( user_id:, name: ) + if user_id.nil? || user_id == '' + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + api_path = '/users/{userId}/name' .gsub('{userId}', user_id) - if user_id.nil? + api_params = { + name: name, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::User + ) + end + + # Get the list of verified passkeys registered by a user. + # + # @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). Maximum of 100 queries are allowed, each 4096 characters long. You may filter and order on the following attributes: $id, $createdAt, $updatedAt, name, accessedAt + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [PasskeyList] + def list_passkeys( + user_id:, + queries: nil, + total: nil + ) + if user_id.nil? || user_id == '' raise Appwrite::Exception.new('Missing required parameter: "userId"') end + api_path = '/users/{userId}/passkeys' + .gsub('{userId}', user_id) + + api_params = { + queries: queries, + total: total, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::PasskeyList + ) + end + + # Get a verified passkey of a user by its unique ID. + # + # @param [String] user_id User ID. + # @param [String] passkey_id Passkey ID. + # + # @return [Passkey] + def get_passkey( + user_id:, + passkey_id: + ) + if user_id.nil? || user_id == '' + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if passkey_id.nil? || passkey_id == '' + raise Appwrite::Exception.new('Missing required parameter: "passkeyId"') + end + + api_path = '/users/{userId}/passkeys/{passkeyId}' + .gsub('{userId}', user_id) + .gsub('{passkeyId}', passkey_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::Passkey + ) + end + + # Rename a passkey of a user. + # + # @param [String] user_id User ID. + # @param [String] passkey_id Passkey ID. + # @param [String] name Passkey name. Max length: 128 chars. + # + # @return [Passkey] + def update_passkey( + user_id:, + passkey_id:, + name: + ) + if user_id.nil? || user_id == '' + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if passkey_id.nil? || passkey_id == '' + raise Appwrite::Exception.new('Missing required parameter: "passkeyId"') + end + if name.nil? raise Appwrite::Exception.new('Missing required parameter: "name"') end + api_path = '/users/{userId}/passkeys/{passkeyId}' + .gsub('{userId}', user_id) + .gsub('{passkeyId}', passkey_id) + api_params = { name: name, } @@ -1184,7 +1275,46 @@ def update_name( path: api_path, headers: api_headers, params: api_params, - response_type: Models::User + response_type: Models::Passkey + ) + end + + # Delete a passkey from a user, for example when a device is lost. The + # passkey can no longer be used to sign in. + # + # @param [String] user_id User ID. + # @param [String] passkey_id Passkey ID. + # + # @return [] + def delete_passkey( + user_id:, + passkey_id: + ) + if user_id.nil? || user_id == '' + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if passkey_id.nil? || passkey_id == '' + raise Appwrite::Exception.new('Missing required parameter: "passkeyId"') + end + + api_path = '/users/{userId}/passkeys/{passkeyId}' + .gsub('{userId}', user_id) + .gsub('{passkeyId}', passkey_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, ) end @@ -1198,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 @@ -1209,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, } @@ -1238,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 @@ -1249,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, } @@ -1276,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 = { @@ -1311,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 @@ -1322,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, } @@ -1351,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, } @@ -1389,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 = { @@ -1421,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( @@ -1453,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( @@ -1491,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 @@ -1502,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, } @@ -1533,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, @@ -1577,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 @@ -1596,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, @@ -1629,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 = { @@ -1673,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, @@ -1716,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( @@ -1759,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, @@ -1796,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 @@ -1807,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, } @@ -1836,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 @@ -1847,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 c0b1fa6e..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] @@ -119,15 +119,18 @@ def list_specifications() # List transactions across all databases. # # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [TransactionList] def list_transactions( - queries: nil + queries: nil, + total: nil ) api_path = '/vectorsdb/transactions' api_params = { queries: queries, + total: total, } api_headers = { @@ -181,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 = { @@ -216,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, @@ -251,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( @@ -283,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, } @@ -318,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 = { @@ -359,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 @@ -370,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, @@ -402,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( @@ -439,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, @@ -489,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 @@ -508,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, @@ -543,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 = { @@ -591,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 @@ -607,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, @@ -641,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( @@ -687,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, @@ -741,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 @@ -761,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, @@ -800,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 @@ -816,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, @@ -854,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 @@ -870,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, @@ -908,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, @@ -956,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, @@ -1010,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, @@ -1061,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, @@ -1118,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, @@ -1175,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, @@ -1227,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, } @@ -1251,6 +1257,7 @@ def delete_document( api_headers = { "X-Appwrite-Project": @client.get_config('project'), "content-type": 'application/json', + "accept": 'application/json', } @client.call( @@ -1275,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, @@ -1328,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 @@ -1352,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, @@ -1387,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 = { @@ -1432,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( @@ -1482,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, } @@ -1525,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, @@ -1561,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 = { @@ -1594,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 new file mode 100644 index 00000000..24a3b0f7 --- /dev/null +++ b/lib/appwrite/services/waf.rb @@ -0,0 +1,859 @@ +# frozen_string_literal: true + +module Appwrite + class Waf < Service + def initialize(client) + @client = client + end + + # List WAF rules for the current project. + # + # + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + # @param [String] search Search term to filter your list results. Max length: 256 chars. + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [WafRuleList] + def list_rules( + queries: nil, + search: nil, + total: nil + ) + api_path = '/waf/rules' + + api_params = { + queries: queries, + search: search, + total: total, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleList + ) + end + + # Create a bypass WAF rule. Conditions can match request attributes including + # `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, + # `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, + # `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + # `browserVersion`. Conditions on `city` and `state` require the premium Geo + # DB addon. + # + # + # @param [String] rule_id Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] name Rule name. + # @param [String] resource_id Resource identifier. Leave empty for the API resource type. + # @param [String] description Optional description for the rule. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to create the rule in a disabled state. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleBypass] + def create_bypass_rule( + rule_id:, + resource_type:, + name:, + resource_id: nil, + description: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + if resource_type.nil? + raise Appwrite::Exception.new('Missing required parameter: "resourceType"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + api_path = '/waf/rules/bypass' + + api_params = { + ruleId: rule_id, + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleBypass + ) + end + + # Update a bypass WAF rule. Conditions can match request attributes including + # `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, + # `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, + # `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + # `browserVersion`. Conditions on `city` and `state` require the premium Geo + # DB addon. + # + # + # @param [String] rule_id Rule ID. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] name Rule name. + # @param [String] description Optional description for the rule. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to disable the rule. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleBypass] + def update_bypass_rule( + rule_id:, + resource_type: nil, + resource_id: nil, + name: nil, + description: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? || rule_id == '' + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + api_path = '/waf/rules/bypass/{ruleId}' + .gsub('{ruleId}', rule_id) + + api_params = { + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleBypass + ) + end + + # Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to + # tune the client-side proof-of-work cost, and `ttl` to control how long, in + # seconds, a visitor stays cleared after passing the challenge before being + # challenged again. Conditions can match request attributes including `ip` + # (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, + # `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, + # `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions + # on `city` and `state` require the premium Geo DB addon. + # + # + # @param [String] rule_id Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] name Rule name. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] description Optional description for the rule. + # @param [String] challenge_type Challenge type enforced by the rule. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to create the rule in a disabled state. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # @param [Integer] difficulty Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + # @param [Integer] ttl How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + # + # @return [WafRuleChallenge] + def create_challenge_rule( + rule_id:, + resource_type:, + name:, + resource_id: nil, + description: nil, + challenge_type: nil, + priority: nil, + enabled: nil, + conditions: nil, + difficulty: nil, + ttl: nil + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + if resource_type.nil? + raise Appwrite::Exception.new('Missing required parameter: "resourceType"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + api_path = '/waf/rules/challenge' + + api_params = { + ruleId: rule_id, + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + challengeType: challenge_type, + priority: priority, + enabled: enabled, + conditions: conditions, + difficulty: difficulty, + ttl: ttl, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleChallenge + ) + end + + # Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to + # tune the client-side proof-of-work cost, and `ttl` to control how long, in + # seconds, a visitor stays cleared after passing the challenge before being + # challenged again. Conditions can match request attributes including `ip` + # (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, + # `country`, `continent`, `headers.<name>`, `query.<key>`, `queryKeys`, + # `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions + # on `city` and `state` require the premium Geo DB addon. + # + # + # @param [String] rule_id Rule ID. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] name Rule name. + # @param [String] description Optional description for the rule. + # @param [String] challenge_type Challenge type enforced by the rule. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to disable the rule. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # @param [Integer] difficulty Challenge difficulty from 1 (easiest) to 5 (hardest). Higher values demand more client-side proof-of-work. + # @param [Integer] ttl How long, in seconds, a visitor stays cleared after passing the challenge before being challenged again. + # + # @return [WafRuleChallenge] + def update_challenge_rule( + rule_id:, + resource_type: nil, + resource_id: nil, + name: nil, + description: nil, + challenge_type: nil, + priority: nil, + enabled: nil, + conditions: nil, + difficulty: nil, + ttl: nil + ) + if rule_id.nil? || rule_id == '' + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + api_path = '/waf/rules/challenge/{ruleId}' + .gsub('{ruleId}', rule_id) + + api_params = { + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + challengeType: challenge_type, + priority: priority, + enabled: enabled, + conditions: conditions, + difficulty: difficulty, + ttl: ttl, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleChallenge + ) + end + + # Create a deny WAF rule. Conditions can match request attributes including + # `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, + # `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, + # `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + # `browserVersion`. Conditions on `city` and `state` require the premium Geo + # DB addon. + # + # + # @param [String] rule_id Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] name Rule name. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] description Optional description for the rule. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to create the rule in a disabled state. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleDeny] + def create_deny_rule( + rule_id:, + resource_type:, + name:, + resource_id: nil, + description: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + if resource_type.nil? + raise Appwrite::Exception.new('Missing required parameter: "resourceType"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + api_path = '/waf/rules/deny' + + api_params = { + ruleId: rule_id, + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleDeny + ) + end + + # Update a deny WAF rule. Conditions can match request attributes including + # `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, + # `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, + # `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + # `browserVersion`. Conditions on `city` and `state` require the premium Geo + # DB addon. + # + # + # @param [String] rule_id Rule ID. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] name Rule name. + # @param [String] description Optional description for the rule. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to disable the rule. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleDeny] + def update_deny_rule( + rule_id:, + resource_type: nil, + resource_id: nil, + name: nil, + description: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? || rule_id == '' + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + api_path = '/waf/rules/deny/{ruleId}' + .gsub('{ruleId}', rule_id) + + api_params = { + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleDeny + ) + end + + # Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits + # per client IP, while `userId` limits per authenticated user (requests + # without an authenticated user skip `userId` rules). Conditions can match + # request attributes including `ip` (plain IPs or CIDR blocks like + # `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, + # `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, + # `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and + # `state` require the premium Geo DB addon. + # + # + # @param [String] rule_id Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] name Rule name. + # @param [Integer] limit Maximum number of matching requests allowed in the configured interval. + # @param [Integer] interval Interval in seconds used for rate limiting. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] description Optional description for the rule. + # @param [String] key Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + # @param [String] strategy Rate limit strategy. `fixedWindow` counts requests in discrete intervals, `slidingWindow` weights the previous interval for smoother limiting, and `tokenBucket` refills allowance continuously to permit short bursts. + # @param [Integer] max_bucket_size Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Defaults to `limit` when omitted. Ignored by other strategies. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to create the rule in a disabled state. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleRateLimit] + def create_rate_limit_rule( + rule_id:, + resource_type:, + name:, + limit:, + interval:, + resource_id: nil, + description: nil, + key: nil, + strategy: nil, + max_bucket_size: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + if resource_type.nil? + raise Appwrite::Exception.new('Missing required parameter: "resourceType"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if limit.nil? + raise Appwrite::Exception.new('Missing required parameter: "limit"') + end + + if interval.nil? + raise Appwrite::Exception.new('Missing required parameter: "interval"') + end + + api_path = '/waf/rules/rate-limit' + + api_params = { + ruleId: rule_id, + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + limit: limit, + interval: interval, + key: key, + strategy: strategy, + maxBucketSize: max_bucket_size, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleRateLimit + ) + end + + # Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits + # per client IP, while `userId` limits per authenticated user (requests + # without an authenticated user skip `userId` rules). Conditions can match + # request attributes including `ip` (plain IPs or CIDR blocks like + # `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, + # `headers.<name>`, `query.<key>`, `queryKeys`, `userAgent`, `os`, + # `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and + # `state` require the premium Geo DB addon. + # + # + # @param [String] rule_id Rule ID. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] name Rule name. + # @param [String] description Optional description for the rule. + # @param [Integer] limit Maximum number of matching requests allowed in the configured interval. + # @param [Integer] interval Interval in seconds used for rate limiting. + # @param [String] key Rate limit key. Use `ip` to limit per client IP or `userId` to limit per authenticated user. Requests without an authenticated user skip `userId` rules. + # @param [Integer] max_bucket_size Maximum number of tokens the bucket can hold for the `tokenBucket` strategy, controlling how large a burst is allowed. The sustained refill rate is `limit / interval`. Ignored by other strategies. The strategy itself cannot be changed after creation. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to disable the rule. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleRateLimit] + def update_rate_limit_rule( + rule_id:, + resource_type: nil, + resource_id: nil, + name: nil, + description: nil, + limit: nil, + interval: nil, + key: nil, + max_bucket_size: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? || rule_id == '' + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + api_path = '/waf/rules/rate-limit/{ruleId}' + .gsub('{ruleId}', rule_id) + + api_params = { + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + limit: limit, + interval: interval, + key: key, + maxBucketSize: max_bucket_size, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleRateLimit + ) + end + + # Create a redirect WAF rule. Conditions can match request attributes + # including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, + # `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, + # `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + # `browserVersion`. Conditions on `city` and `state` require the premium Geo + # DB addon. + # + # + # @param [String] rule_id Rule ID. Choose a custom ID or pass `ID.unique()` to generate a unique one. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] name Rule name. + # @param [String] location Location used for redirect responses. + # @param [Integer] status_code Integer status code used for redirect responses. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] description Optional description for the rule. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to create the rule in a disabled state. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleRedirect] + def create_redirect_rule( + rule_id:, + resource_type:, + name:, + location:, + status_code:, + resource_id: nil, + description: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + if resource_type.nil? + raise Appwrite::Exception.new('Missing required parameter: "resourceType"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if location.nil? + raise Appwrite::Exception.new('Missing required parameter: "location"') + end + + if status_code.nil? + raise Appwrite::Exception.new('Missing required parameter: "statusCode"') + end + + api_path = '/waf/rules/redirect' + + api_params = { + ruleId: rule_id, + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + location: location, + statusCode: status_code, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleRedirect + ) + end + + # Update a redirect WAF rule. Conditions can match request attributes + # including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, + # `path`, `host`, `country`, `continent`, `headers.<name>`, `query.<key>`, + # `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + # `browserVersion`. Conditions on `city` and `state` require the premium Geo + # DB addon. + # + # + # @param [String] rule_id Rule ID. + # @param [String] resource_type Resource type the rule applies to. + # @param [String] resource_id Resource identifier. Required for functions and sites. + # @param [String] name Rule name. + # @param [String] description Optional description for the rule. + # @param [String] location Location used for redirect responses. + # @param [Integer] status_code Integer status code used for redirect responses. + # @param [Integer] priority Evaluation priority. Lower numbers run earlier. + # @param [] enabled Set to false to disable the rule. + # @param [Array] conditions Array of condition strings generated using the WAF Condition builder. Maximum of 100 conditions are allowed, each 4096 characters long. + # + # @return [WafRuleRedirect] + def update_redirect_rule( + rule_id:, + resource_type: nil, + resource_id: nil, + name: nil, + description: nil, + location: nil, + status_code: nil, + priority: nil, + enabled: nil, + conditions: nil + ) + if rule_id.nil? || rule_id == '' + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + api_path = '/waf/rules/redirect/{ruleId}' + .gsub('{ruleId}', rule_id) + + api_params = { + resourceType: resource_type, + resourceId: resource_id, + name: name, + description: description, + location: location, + statusCode: status_code, + priority: priority, + enabled: enabled, + conditions: conditions, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::WafRuleRedirect + ) + end + + # Get a WAF rule by its ID. + # + # + # @param [String] rule_id Rule ID. + # + # @return [WafRuleBypass, WafRuleDeny, WafRuleChallenge, WafRuleRateLimit, WafRuleRedirect] + def get_rule( + rule_id: + ) + if rule_id.nil? || rule_id == '' + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + api_path = '/waf/rules/{ruleId}' + .gsub('{ruleId}', rule_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + response = @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + ) + + unless response.is_a?(Hash) + raise Exception, "Expected object response when hydrating a response model" + end + + if response['action'] == 'bypass' + + return Models::WafRuleBypass.from(map: response) + end + + if response['action'] == 'deny' + + return Models::WafRuleDeny.from(map: response) + end + + if response['action'] == 'challenge' + + return Models::WafRuleChallenge.from(map: response) + end + + if response['action'] == 'rateLimit' + + return Models::WafRuleRateLimit.from(map: response) + end + + if response['action'] == 'redirect' + + return Models::WafRuleRedirect.from(map: response) + end + + raise Exception, "Unable to match response to any expected response model" + end + + # Delete a WAF rule. + # + # + # @param [String] rule_id Rule ID. + # + # @return [] + def delete_rule( + rule_id: + ) + if rule_id.nil? || rule_id == '' + raise Appwrite::Exception.new('Missing required parameter: "ruleId"') + end + + api_path = '/waf/rules/{ruleId}' + .gsub('{ruleId}', rule_id) + + api_params = {} + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + end + end +end 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